2 ms·
Jq can do lots of things that are similar to what’s normally done with awk, cut, sed, and grep. The languages pipeline model is slightly opaque (eg as soon as y
by dan-robertson 7y ago
Jq can do lots of things that are similar to what’s normally done with awk, cut, sed, and grep. The languages pipeline model is slightly opaque (eg as soon as you use a function like select) and I feel tricky to get the hang of but overall I think it works well for the kind of job jq does.
That said, I usually get on well with a halfway house of piping jq -c ... into eg grep or sort -u for easy processing (-c writes one json object per line, aka compact form), or selecting a few elements, putting them in an array, jq-piping into @csv, and passing -r to get raw output which I can then process with awk or sort or other Unix commands.
One subtle caveat is that jq normalises all the json it processes, so for example escaped characters in strings may change and numbers which are not IEEE doubles get converted (eg if someone writes a 64-bit int or a bignum as a number not a string in the json)