Created
July 27, 2016 01:15
-
-
Save mzipay/d5609150c32945db1bb4519dc2553610 to your computer and use it in GitHub Desktop.
BaSH function to validate & pretty-print JSON from a file or stdin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ppjson { | |
test -f "${1}" && src="open('${1}')" || src="sys.stdin" | |
python -c "import json,sys;sys.stdout.write(json.dumps(json.load(${src}),indent=2)+'\n')" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment