Live data from Hacker News

Extracting Objects Recursively with Jq

til.simonwillison.net

21–30 of 76 posts

Re: Extracting Objects Recursively with Jq

#22

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 include…

If anyone is an emacs user and this sounds compelling, I recommend counsel-jq[0] for the sort of feedback loop described here.

[0]: https://github.com/200ok-ch/counsel-jq

Re: Extracting Objects Recursively with Jq

#24
post #10

I've really loved having jq at my disposal ever since learning about it, but I feel like it took the combination of it and gron [1] to really transform my debugging and JSON workflows. 1: https://github.com/TomNomNom/gron

I can't believe the number of times I've wanted to grep a JSON file, and yet never thought to look and see if there was any kind of tool for it. Thanks!

Re: Extracting Objects Recursively with Jq

#25
post #2

jq seems incredibly powerful. I only find myself using it a few times a year though, and have never been able to conceptualize the syntax enough to use it without prodigious googling.

Think of it just like bash. jq is the ultimate functional language and/or ETL tool. If I look back at larger jq transforms I've written a while ago (e.g. https://git.io/JBSfB ) they still make perfect sense to me.

[deleted]

Re: Extracting Objects Recursively with Jq

#26
post #12

I love jq for many reasons: * it is very potent * it has extensive documentation, written more like parabolas and new-age sorcery than actually helpful content * it improves your search skills greatly, for many internet results try to give sense to its format * it gives great satisfaction after you've died-and-retried 300x a whole afternoon for a command you'll only need once. * it looks cool to use jq instead of [an…

Jq makes me feel stupid, it's comforting to know that it's probably not just me.

Re: Extracting Objects Recursively with Jq

#29

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 include…

That’s cool! What’s the use of FZF? Isn’t it a fuzzy finder, what are you searching for in a jq REPL?

Re: Extracting Objects Recursively with Jq

#30
I often use jq for random hacks but for something like this I would turn to XPath. I know that sounds impossibly retro, but XPath 3.1 for JSON is awesome and its language makes so much more sense than jq’s. There are several good implementations, and all of them are faster than jq, too.
Post reply on HN