Skip to content

Instantly share code, notes, and snippets.

@mzipay
Created July 27, 2016 01:15
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 mzipay/d5609150c32945db1bb4519dc2553610 to your computer and use it in GitHub Desktop.
Save mzipay/d5609150c32945db1bb4519dc2553610 to your computer and use it in GitHub Desktop.
BaSH function to validate & pretty-print JSON from a file or stdin
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