Created
January 4, 2012 20:03
-
-
Save braveulysses/1561782 to your computer and use it in GitHub Desktop.
JSON pretty print
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 | |
import sys | |
try: | |
import json | |
except ImportError: | |
print "Can't import JSON module. Make sure you're using Python 2.6 or above." | |
sys.exit(1) | |
try: | |
data = json.load(sys.stdin) | |
except ValueError: | |
print "Couldn't parse input as JSON." | |
sys.exit(1) | |
print json.dumps(data, indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment