Created
November 12, 2014 07:11
-
-
Save cobusc/f476f27fb4a9856970dc to your computer and use it in GitHub Desktop.
Utility to validate, pretty-print and syntax highlight JSON data
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
#!/bin/bash | |
# | |
# Utility to display JSON data in a pretty-printed, syntax highlighted form. | |
# If the data is not valid JSON, an error will be reported. | |
# | |
# An optional filename can be specified, otherwise input is read from stdin. | |
# | |
set -o pipefail | |
JSON=$(cat ${1:-/dev/stdin} | python -mjson.tool) | |
if [ $? -eq 0 ]; then | |
vi -R -c "set syntax=javascript" -c "set bg=dark" - <<< "${JSON}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment