5_qtfa
Last Updated: February 25, 2016
·
896
· mrallen1
7330b65ea54e1b90a987a552e5c5cf32

Pretty print JSON from the command line using python

Python's out of the box JSON library is pretty badass although I tend to use simplejson in my code.

One of the coolest things about it is the JSON tool, which you can invoke easily using the -m option in python.

For example, if you wanted to query a REST endpoint and pretty print the result, you can use something like

curl -s http://example.com/api/v1/frobulate | python -mjson.tool

Say Thanks
Respond