An example method for fetching remote JSON data in Ruby.

Source 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)

[Login or Register to remove this advertisement]

end
 
puts fetch 
"http://example.org/sample.json" 
Mobile_Guru Reviewed by Mobile_Guru on . Fetch remote JSON in Ruby An example method for fetching remote JSON data in Ruby. require 'rubygems' require 'json' require 'net/http' def fetch(url) resp = Net::HTTP.get_response(URI.parse(url)) data = resp.body JSON.parse(data) Rating: 5