Last active
March 6, 2018 05:26
-
-
Save cedmundo/8329918748e9572238cd81da17d32f6b to your computer and use it in GitHub Desktop.
Simple script that helps to debug output of curl while testing some HTTP API endpoints, if cannot parse JSON then will show up as lynx page.
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
#!/usr/bin/env bash | |
content=`cat /dev/stdin` | |
value=`echo $content | python -m 'json.tool' 2>&1` | |
if [ "$value" == "No JSON object could be decoded" ]; then | |
echo "$content" | lynx -stdin | |
else | |
echo "$value" | pygmentize -l json | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires pygmentize (or just remove it 🙃 ), lynx and python.