Reading json

Sometimes when you are working with devops tools you will find yourself staring at a wall of JSON. Perhaps the JSON is many lines long, and you are working from the command line. You need to easily and quickly pick out a piece of it to verify a value. What do you do?

A long, hard-to-read string of json
Your wall of JSON. Sample JSON from

Reading from the wall

That is hard to read! Did you know Python can help you?

Try this instead: python -m json.tool wall_of.json

JSON displayed in a way that is easier to read
This JSON breathes

That is much easier to read than a wall of text! json.tool printed each item on its own line, and sorted the arrays and hash keys.

If the data structure is simple, you can grep for names and values. Although one could point to that as a “hack”, it is very quick and needs no additional tools.