JJ: JSON Stream Editor
github.com
JJ: JSON Stream Editor
1–10 of 50 posts
Re: JJ: JSON Stream Editor
#2Re: JJ: JSON Stream Editor
#3Re: JJ: JSON Stream Editor
#4I 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
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)
Re: JJ: JSON Stream Editor
#5Re: JJ: JSON Stream Editor
#6For those wondering, the README states it's a lot faster than JQ, which may be the selling point.
Re: JJ: JSON Stream Editor
#7I 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
I 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)
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"].
Re: JJ: JSON Stream Editor
#8For those wondering, the README states it's a lot faster than JQ, which may be the selling point.
However, jsonptr is even faster and also runs in a self-imposed SECCOMP_MODE_STRICT sandbox (very secure; also implies no dynamically allocated memory).
$ time cat citylots.json | jq -cM .features[10000].properties.LOT_NUM
"091"
real 0m4.844s
$ time cat citylots.json | jj -r features.10000.properties.LOT_NUM
"091"
real 0m0.210s
$ time cat citylots.json | jsonptr -q=/features/10000/properties/LOT_NUM
"091"
real 0m0.040s
jsonptr's query format is RFC 6901 (JSON Pointer). More details are at
https://nigeltao.github.io/blog/2020/jsonptr.htmlRe: JJ: JSON Stream Editor
#9Re: JJ: JSON Stream Editor
#10There might be a nice 'edit just this path in-place in gron-style' recipe to be had out of jj/jq + gron together...