Using Ruby on Rails to fetch and parse JSON from another web service Using Ruby on Rails to fetch and parse JSON from another web service json json

Using Ruby on Rails to fetch and parse JSON from another web service


Try something like this

require 'open-uri'require 'json'result = JSON.parse(open("url_of_json_service").read)

See more abut the JSON gem here: http://flori.github.com/json/


I've never had to do this so these are just some ideas to look into...

If you're doing this from client side you could probably just make a JSONP request and manipulate the JSON object however you want.

Otherwise, if you want to make these calls from your server, you'd probably want to look into the Ruby Net HTTP library.

Then to serialize and deserialize JSON you can use this gem. It's the first one I found. There are probably others.