4 ms·
I agree that jq's query language is very obtuse and probably my biggest barrier towards learning it. I have found great mileage using gron [1], which is very di
by 1_player 5y ago
I agree that jq's query language is very obtuse and probably my biggest barrier towards learning it. I have found great mileage using gron [1], which is very different from jq, but its goal is to promote exploration of a JSON file through common unix tools such as awk and grep.
1: https://github.com/tomnomnom/gron https://github.com/tomnomnom/gron
- mongol 5y agoI want to vouch for gron as well. Apart from being grepable, I found it is easier to orient myself where I am in a very large JSON structure. The location in the hierarchy is present on every single line, no need to scroll up or down to figure it out. Granted, many other tools can help with this as well, but gron does it well.
- skywal_l 5y agoLove this. Such a simple idea yet very helpful. It probably can't do what all jq does but it will solve most of what you usually want to do with json on the command line. Thanks for that tip!
- zimpenfish 5y ago> I have found great mileage using gron `gron` is great but doesn't seem to handle some (extreme-ish) situations that `jq` can, e.g. the json output from the fastnbt-tools. You either get a `token too long` error using `gron -s` because the input is too long (it's 90MB, that's fair) or you get only one set of outputs per key (iyswim) because they get overlapped in memory.
- codetrotter 5y ago> or you get only one set of outputs per key (iyswim) because they get overlapped in memory That sounds like a major bug. So it will silently skip data that you wanted?
- zimpenfish 5y ago> That sounds like a major bug. It's definitely an oddness when you have multiple objects at the same level that aren't in an array but I guess the explanation there is "they should all be on their own individual lines as streaming json" which `gron` does handle correctly. (echo '{"a":"23"}'; echo '{"a":"25"}') | gron -s json = []; json[0] = {}; json[0].a = "23"; json[1] = {}; json[1].a = "25"; > So it will silently skip data that you wanted? Yeah. echo '{"a":"23"}{"a":"25"}' | gron json = {}; json.a = "23"; The `-s` option doesn't help. echo '{"a":"23"}{"a":"25"}' | gron -s json = []; json[0] = {}; json[0].a = "23";
- zimpenfish 5y agoHad a look at the source and I think I've figured out why and maybe how to fix it. Will have a bash at making a PR this week.