Created
November 25, 2015 00:16
-
-
Save mossprescott/0bb9038dfd5acc8bdb2e to your computer and use it in GitHub Desktop.
Command-line pretty-priner for JSON (one value, can be multi-line)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/local/bin/python | |
| # Slightly modified from the module's own __main__ behavior (according to the interwebs). | |
| import sys, json | |
| infile = sys.stdin | |
| outfile = sys.stdout | |
| with infile: | |
| obj = json.load(infile) | |
| with outfile: | |
| json.dump(obj, outfile, indent=2, separators=(',', ': ')) | |
| outfile.write('\n') # final newline for usability in the shell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment