Skip to content

Instantly share code, notes, and snippets.

@braveulysses
Created January 4, 2012 20:03
Show Gist options
  • Save braveulysses/1561782 to your computer and use it in GitHub Desktop.
Save braveulysses/1561782 to your computer and use it in GitHub Desktop.
JSON pretty print
#!/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