prettyJson.py 350 Bytes
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import json, sys
from pprint import pprint

if not sys.stdin.isatty():
JSON = json.loads(sys.stdin.read())
pprint(JSON)
else:
print("Use this script with a pipe command.")
print("")
print("echo '...' | python3 prettyJson.py")
print("or")
print("cat ... | python3 prettyJson.py")