HTTPリクエストでJSONが返ってくるAPIを処理するとかよくあるケースだけど、意外と書き方忘れるのでメモ require 'net/http' require 'uri' require 'json' uri = URI.parse('http://www.example.com/sample.json') json = Net::HTTP.get(uri) result = JSON.parse(json) puts result require 'net/http' require 'uri' require 'json' def get_json(location, limit = 10) raise ArgumentError, 'too many HTTP redirects' if limit == 0 uri = URI.parse(location) begin res