Commit ddcbdc4f9f890ad67c4baf32b40da275d0dcc5f5
1 parent
b8d82201ba
Exists in
master
added
Showing 1 changed file with 15 additions and 0 deletions
prettyJson.py
View file @
ddcbdc4
1 | +#!/usr/bin/python3 | |
2 | +# -*- coding: utf-8 -*- | |
3 | + | |
4 | +import json, sys | |
5 | +from pprint import pprint | |
6 | + | |
7 | +if not sys.stdin.isatty(): | |
8 | + JSON = json.loads(sys.stdin.read()) | |
9 | + pprint(JSON) | |
10 | +else: | |
11 | + print("Use this script with a pipe command.") | |
12 | + print("") | |
13 | + print("echo '...' | python3 prettyJson.py") | |
14 | + print("or") | |
15 | + print("cat ... | python3 prettyJson.py") |