Skip to content

Instantly share code, notes, and snippets.

@cedmundo
Last active March 6, 2018 05:26
Show Gist options
  • Save cedmundo/8329918748e9572238cd81da17d32f6b to your computer and use it in GitHub Desktop.
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.
#!/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
@cedmundo
Copy link
Author

cedmundo commented Oct 31, 2016

Requires pygmentize (or just remove it 🙃 ), lynx and python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment