3 ms·
I like jq, but jj is so fast it is my go-to for pretty printing large json blobs. Its parsing engine is available as a standalone go module, and I've used it in
by cristoperb 3y ago
I like jq, but jj is so fast it is my go-to for pretty printing large json blobs. Its parsing engine is available as a standalone go module, and I've used it in a few projects where I needed faster parsing than encoding/json:
https://github.com/tidwall/gjson https://github.com/tidwall/gjson
- pcthrowaway 3y agoI don't think I've ever been limited by jq's speed, but good to know there are alternatives if it ever becomes a bottleneck. Other than that I can't think of a reason to use this over jq; the query language is perhaps a bit more forgiving in some ways, but not as expressive as jq (and I've spent ~8 years getting pretty familiar with jq's quirks)
- lathiat 3y agoThe limiting speed factor of jq for me is, by far, figuring out how to write the expression I need to parse a fairly small amount of data. I do a bunch of support analysis and often writing a one-liner to put into a shell script to extract some bit of JSON to re-use later in the script. Often this is going to be used only once by me or a customer to run some task. Followed closely by figuring out the path to the area of data I'm interested in. "gron" has been a real time saver there - it converts the json into single lines of key/value - so you can use grep and find the full path for any string. Switching to a GUI to browse the JSON that would let you copy the path to the current value would probably also help there, but, I'm usually in the terminal doing a bunch of different tasks looking through all manor of command outputs, logs, etc :) Relatedly my primary use of ChatGPT has been asking it to write jq queries for me, it's not too bad at getting close. It's biggest blindness seems to be string values with a dash, which you have to write as ["key-name"].
- Simran-B 3y agoI agree that figuring out non-trivial jq expressions takes a lot of time, often accompanied with a consultation of the somewhat lacking docs, and some additional googling. Nonetheless, it is pretty slow at processing data. For example, converting a 1 GB JSON array of objects to JSON Lines takes ages, if it works at all. Using the steaming features helps, but they are hard to comprehend. It gets memory consumption under control and doesn't take super long, but still way too long for such a trivial task IMO.
- pdimitar 3y ago> Switching to a GUI to browse the JSON that would let you copy the path to the current value would probably also help there Try https://jless.io/ https://jless.io/ then.
- Dobbs 3y ago> Switching to a GUI to browse the JSON that would let you copy the path to the current value would probably also help there I use an app called OK JSON on the mac for this. Its okay.
- AeroNotix 3y agoemacs has a command to get the current path at point.
- pdimitar 3y agoWhich one is it exactly, please? I'd like to use it.
- bobnamob 3y agoI’m far more likely to parse json into clojure repl session and go from there these days. Learning jq for the odd json manipulation I need to do seems like overkill
- dicknuckle 3y agoFor me it's usually for some automation task to gather a list of IDs for some cloud environment to build infra things.