Tiny Tip for Better JSON output from curl to a REST API

Add the following to ~/.bashrc:

function jcurl () {
curl $@ --silent | python -m json.tool

so that you get better-looking output for curl queries that return JSON :

curl https://api.github.com/users/mdda/repos
# vs.
jcurl https://api.github.com/users/mdda/repos
## which can be *much* nicer
## (depending on whether the source already sends pretty JSON, of course)

Martin Andrews

{Finance, Software, AI} entrepreneur, living in Singapore with my family.

blog comments powered by Disqus