Created
May 20, 2011 12:57
-
-
Save filipsalo/982839 to your computer and use it in GitHub Desktop.
Simple JSON pretty-printer
This file contains 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/bin/env python | |
# Copyright 2011 Filip Salomonsson <[email protected]> | |
# MIT Licensed | |
# Simple JSON pretty-printer | |
# Save as ~/bin/json and pipe stuff to it. | |
import json | |
import sys | |
src = sys.stdin.read() | |
try: | |
json.dump(json.loads(src), sys.stdout, indent=2) | |
sys.stdout.write("\n") | |
except ValueError: | |
sys.stdout.write(src) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment