#!/usr/local/bin/ruby require 'net/http' require 'uri' require 'json' #url = "http://weather.livedoor.com/forecast/webservice/json/v1?city=011000" #url = "http://www.land.mlit.go.jp/webland/api/TradeListSearch?from=20101&to=20134&station=02590" url = "http://www.land.mlit.go.jp/webland/api/TradeListSearch?from=20101&to=20161&city=13421" uri = URI.parse(url) json = Net::HTTP.get(uri) result = JSON.parse(json) json_str = JSON.pretty_generate(result) #puts json_str (0..100).each do |i| # puts result.dig("data", i, "DistrictName") # puts result.dig("data", i, "PricePerUnit") if result.dig("data", i, "PricePerUnit").to_i <= 10000 puts result.dig("data", i)#, "DistrictName") # puts result.dig("data", i, "PricePerUnit") end end =begin puts result.dig("pinpointLocations", 0, "name")#, "name") puts result.dig("forecasts", 0, "date") puts result.dig("forecasts", 0, "telop") puts result.dig("forecasts", 1, "date") puts result.dig("forecasts", 1, "telop") =end