Skip to content

Instantly share code, notes, and snippets.

@jhsea3do
Forked from thiagophx/pp
Created August 4, 2018 07:02
Show Gist options
  • Save jhsea3do/bfa0e92f0c57ac562493457c0d8e4ac3 to your computer and use it in GitHub Desktop.
Save jhsea3do/bfa0e92f0c57ac562493457c0d8e4ac3 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'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment