Created
November 27, 2013 17:11
-
-
Save mkropat/7679386 to your computer and use it in GitHub Desktop.
Pretty-print JSON data to the console
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 json, sys | |
if len(sys.argv) < 2 or sys.argv[1] == '-': | |
f = sys.stdin | |
else: | |
f = open(sys.argv[1]) | |
json.dump(json.load(f), sys.stdout, indent=4, separators=(',', ': ')) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment