Freenerd
Pretty JSON with curl

When using curl to call REST APIs returning JSON, it is often hard to see the structure of the response. We need to prettify that! Fortunately, the Ruby json gem has a script called “prettify_json.rb”, that we can just pipe JSON to. Awesome.

Install the json gem

gem install json

Use it

$ curl "http://api.soundcloud.com/users/4126.json" | prettify_json.rb

{
  "id": 4126,
  "permalink": "diskodna",
  "username": "DiskoDNA",
  ...
  "website": "http://www.diskodna.de",
  "website_title": null,
  "online": false,
  "track_count": 11,
  "followers_count": 545,
  "followings_count": 311,
  "public_favorites_count": 93
}
Blog comments powered by Disqus