Skip to content

Instantly share code, notes, and snippets.

@axilleas
Forked from timsavery/Ruby Download Parse JSON
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save axilleas/9139208 to your computer and use it in GitHub Desktop.

Select an option

Save axilleas/9139208 to your computer and use it in GitHub Desktop.
require "rubygems"
require "json"
require "net/http"
require "uri"
uri = URI.parse("http://api.sejmometr.pl/posiedzenia/BZfWZ/projekty")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
if response.code == "200"
result = JSON.parse(response.body)
result.each do |doc|
puts doc["id"] #reference properties like this
puts doc # this is the result in object form
puts ""
puts ""
end
else
puts "ERROR!!!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment