Skip to content

Instantly share code, notes, and snippets.

@alukach
Forked from thiagophx/pp
Last active November 25, 2017 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alukach/54268d51dd15c4c5afb5f085b206ec33 to your computer and use it in GitHub Desktop.
Save alukach/54268d51dd15c4c5afb5f085b206ec33 to your computer and use it in GitHub Desktop.
JSON Pretty Print Stream
#!/usr/bin/python -u
import json
import sys
from pygments import highlight
from pygments.lexers import JsonLexer
from pygments.formatters import Terminal256Formatter
for line in sys.stdin:
if line.strip():
print(highlight(
json.dumps(
json.loads(line.strip()),
sort_keys=False,
indent=4,
separators=(',', ': ')
),
JsonLexer(),
Terminal256Formatter(style='paraiso-dark')
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment