pygron
helps you easily analyze and grep through JSON.
It is advisable to install pygron
in a virtual environment.
Clone this repo using the following command:
$ git clone https://github.com/akshbn/pygron $ cd pygron
Install pygron :
python setup.py install
pygron converts JSON into a set of assignment statements. The left hand side of the statement contains the path to the attribute from the root of the JSON object. The right hand side is the value of that attribute.
$ pygron <url>
$ pygron https://api.github.com/repos/akshbn/pygron/commits | grep "commit.author" json[0].commit.author.date = 2016-08-17T11:12:41Z json[0].commit.author.email = [email protected] json[0].commit.author.name = Akshay B N ...
Here date is the attribute, which is present within author which in turn is present within commit.
Pygron also supports reading JSON from a file as well as writing output to a file.
To read json from a file:
$ pygron -f <path to file>
To write output to a file:
$ pygron <url> -w
pygron will write into a file called pygron_output.txt in the current working directory.
Use $ pygron -h
to learn more about the commandline options available.
Note: This is a python implementation of gron.