It seems many people here use jq to browse JSON files. I've been
referred recently to gron <https://github.com/tomnomnom/gron> which is
quite different: less features but probably simpler to use for
beginners. Unlike jq, gron does not have a filtering language: it just
formats the JSON in a way that makes simple to use traditional grep.

Here is an example with measurement #4477822, a DNS one:

% gron 4477822.json|more       
json = [];
json[0] = {};
json[0].from = "178.248.214.8";
json[0].fw = 4730;
json[0].group_id = 4477822;
json[0].lts = 18;
...

Selecting the values of the serial number is as simple as:

% gron 4477822.json | grep SERIAL
json[0].resultset[0].result.answers[0].SERIAL = 2223898795;
json[0].resultset[1].result.answers[0].SERIAL = 2223898793;
json[1].resultset[0].result.answers[0].SERIAL = 2223898790;
json[1].resultset[1].result.answers[0].SERIAL = 2223898792;
json[1].resultset[2].result.answers[0].SERIAL = 2223898795;
json[2].resultset[0].result.answers[0].SERIAL = 2223898791;
...

And you can turn back the result of the filtering into JSON.


Reply via email to