Prettyprinting JSON with Python
There are a number really awesome tools that can be used to view and validate JSON files right from the command line. As it turns out, one such tool is built right into Python as the json.tool module. Usage is as follows:
python -m json.tool [-h] [--sort-keys] [infile] [outfile]
If a single argument is given, it will validate the file and (pretty) print it to stdout.
This is all good and dandy, but what if I want to edit this JSON file now. I could always write it to an output file and edit that, but that’s just extra steps to take. To bring this trick to another level of handiness, I added this mapping to my vimrc.