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
Written by Mark Allen
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#