01mf02 / jaq

A jq clone focussed on correctness, speed, and simplicity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Native" filters for jaq-core

passcod opened this issue · comments

It would be nice to be able to define custom Filter definitions that call Rust rather than being pure jaq.

I'm exploring using jaq to provide powerful user-defined filtering for an application but for maximum utility I want to provide access to key-value data in the application context, something like string | store("key") and fetch("key") -> string.

Short of forking I don't see a way to provide a Filter that's implemented in Rust rather than as jaq definitions.

If implemented i would suggest custom filters should be able to return some kind of iterator to make them more useful and fit nicely into rest of jq.

gojq implements it by having https://pkg.go.dev/github.com/itchyny/gojq#WithFunction and https://pkg.go.dev/github.com/itchyny/gojq#WithIterFunction

(this also should make implement eval possible with not much effort)

I find that an interesting idea, @passcod. I would be happy to accept a PR that implements this.

That turned out to be pretty straightforward. I'll submit a PR tomorrow.