Also for anything where jq gets too complicated, you can use python to whip
up an arbitrary json filter
Theres only 5 lines of boiler plate
import json
import sys
d = json.load(sys.stdin)
# your code here
print(json.dumps(d))
Tyler
On Wed, Jan 22, 2020, 09:22 <arnold(a)skeeve.com> wrote:
On Sat, Jan
18, 2020 at 09:45:22AM -0600, Michael Parson wrote:
>
> And here, understanding the model is important, namely, grep is the
> wrong tool for searching/parsing JSON output. Dealing with JSON from
the
> shell, you should use jq. I've been
dragged kicking and screaming into
> dealing with JSON, and about all I can say about it is, I like it about
> this >< much more than XML. :)
Derek Fawcus <dfawcus+lists-tuhs(a)employees.org> wrote:
If push comes to shove, one can always use xmlawk
(xml extension for
gawk)
to beat the latter in to submission.
There is also a simple JSON extension for gawk in the gawkextlib project
that can suck in a single JSON record and turn it into a gawk
multidimensional array, and vice versa. (Gawk has true multidimensional
arrays and isarray/typeof functions so that you can easily traverse
such an array.)
(<horn ownership="mine">Toot!</horn>)
Arnold