Skip to content

Instantly share code, notes, and snippets.

@thiagophx
Created March 17, 2015 18:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save thiagophx/9d6b06891a1ce3c707a7 to your computer and use it in GitHub Desktop.
Save thiagophx/9d6b06891a1ce3c707a7 to your computer and use it in GitHub Desktop.
JSON Pretty Print Stream
#!/usr/bin/python -u
import sys, json
from pygments import highlight
from pygments.lexers import JsonLexer
from pygments.formatters import Terminal256Formatter
while True:
line = sys.stdin.readline()
if line.strip():
print highlight(json.dumps(json.loads(line.strip()), sort_keys=False, indent=4, separators=(',',': ')), JsonLexer(), Terminal256Formatter(style='paraiso-dark'))
@MiniRalis
Copy link

Awesome, this Gist let me show off the power of JSON in beautiful color!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment