-
-
Save douglasmartins7/d063e2d3d727c215fd5a538d5d68fe02 to your computer and use it in GitHub Desktop.
Example For Downloading and Parsing JSON (Ruby)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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