We can use the open-uri
to get the content from the url. And use the JSON
to parse the JSON string to hash or array.
require 'open-uri'
require 'JSON'
url = "https://api.com/result.json"
json = open(url).read
objs = JSON.parse(json)
objs.each do |obj|
title = obj["title"]
end
If the result is not a array. The result will be a dictionary. Just use like this:
obj = JSON.parse(json)
title = obj["title"]