Support for jq functions (eg `keys`)
DanielHeath opened this issue · 6 comments
Thanks for releasing this - I'm a big fan :)
Is there interest in covering off more of the jq
builtins?
For instance:
echo '{"abc": 1, "abcd": 2, "Foo": 3}' | jq 'keys'
["Foo", "abc", "abcd"]
jid prevents me typing keys
at all at the moment.
This could maybe include jq
as a submodule or something, to not reinvent the well
You can use Ctrl+L to view a list of keys available at time when you're digging a query.
Shameless self-promotion: jiq, my fork of jid uses jq
and supports all the fancy queries, operators and functions it offers.
So, jid
doesn't actually use jq, so this can't quite be done... :( However, @fiatjaf's jiq
fork of jid
does, which is pretty cool. It might be nice to have golang bindings for libjq
to avoid having to create a new process every time... Oh wait! There is at least one: https://github.com/threatgrid/jq-go !
That's awesome. I should use that in jiq but maybe it would be better if it got used on jid instead.
@fiatjaf yeah.
I've got a branch in my jq clone that adds FFIs, I/O, co-routines, eval. After it gets integrated we'll be able to build a REPL out of eval. jid shows me that a REPL shell should really use curses so as to leave the program in the same part of the terminal screen, and show/page results in another.
Besides the jq-go mentioned in #33 (comment) above, there is also https://github.com/itchyny/gojq as a Go library for jq query.