Extracting Objects Recursively with Jq
I tend to use jq a lot. As others have said, sometimes jq can be hard to grasp. Often it requires multiple attempts to get the correct answer. To make it a little easier for me, I've written a helper function[0] that combines it with fzf[1] to run jq as a REPL on any json. It allows to incrementally alter your DSL without having to continually call jq. This is similar to jid/jiq but a little more powerful. It includes functions to change the preview to output raw, compact (or not), and some other things.<p>It is essentially similar to jqplay but local.<p>I didn't use jid/jiq because jid uses go-simplejson, which is nowhere near as powerful as jq, and jiq seemed very buggy when I used it and it felt like it was hacked together. Plus there was no where to change jq's arguments while running it.<p>I'm sure this function can be improved on, but this has been good enough for me so far.<p>Also, I run gojq[2] instead of jq. It is a drop-in replacement for jq but is written in Go, and has some improvements over jq such as bug fixes, support for yaml input, and it also provides more helpful error messages.<p>[0] <a href="https://github.com/hoshsadiq/dot_files/blob/master/zshrc.d/misc/fuzzy.zsh#L27-L159" rel="nofollow">https://github.com/hoshsadiq/dot_files/blob/master/zshrc.d/m...</a><p>[1] <a href="https://github.com/junegunn/fzf" rel="nofollow">https://github.com/junegunn/fzf</a><p>[2] <a href="https://github.com/itchyny/gojq/" rel="nofollow">https://github.com/itchyny/gojq/</a>