khym-w
Last Updated: April 19, 2019
·
3.781K
· felipeelias

Pretty print JSON responses with curl/ruby

Ruby only

curl -s "http://someapi.com/json" | ruby -rjson -e 'print JSON.pretty_generate(JSON.parse(STDIN.read))'

With awesome_print gem

curl -s "http://someapi.com/json" | ruby -rawesome_print -rjson -e 'ap JSON.parse(STDIN.read)'

3 Responses
Add your response

17459

Thanks for this! Here's what I've got in my env:

function jcurl { curl $* | ruby -rawesome_print -rjson -e 'ap JSON.parse(STDIN.read)' }
export -f jcurl

Now just
jcurl -s "http://someapi.com/json"

over 1 year ago ·
24707

For color and more options, try piping to jq https://stedolan.github.io/jq/

curl -s "https://api.github.com" | jq

And then...

curl -s "https://api.github.com" | jq .user_search_url
over 1 year ago ·
32583

Mozilla Firefox if you are know the information and you have change our web browser and you are feel the working information are there and you have connect https://foxdownload.org the more useful website and you have enjoy the new working web browser.

4 days ago ·