Skip to content

Instantly share code, notes, and snippets.

@filipsalo
Created May 20, 2011 12:57
Show Gist options
  • Save filipsalo/982839 to your computer and use it in GitHub Desktop.
Save filipsalo/982839 to your computer and use it in GitHub Desktop.
Simple JSON pretty-printer
#!/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