Return to Snippet

Revision: 54040
at December 7, 2011 23:55 by vestimir


Initial Code
require 'rubygems'
require 'json'
require 'net/http'

def fetch(url)
   resp = Net::HTTP.get_response(URI.parse(url))
   data = resp.body
   JSON.parse(data)
end

puts fetch "http://example.org/sample.json"

Initial URL

                                

Initial Description
An example method for fetching remote JSON data in Ruby.

Initial Title
Fetch remote JSON in Ruby

Initial Tags
rails, ruby, web, json

Initial Language
Ruby