Ruby - iterate over parsed JSON Ruby - iterate over parsed JSON ruby ruby

Ruby - iterate over parsed JSON


You're trying to iterate over data, which is a hash, not a list. You need to get the children array from your JSON object by data['data']['children']

require "net/http"require "uri"require "json"uri = URI.parse("http://www.reddit.com/user/brain_poop/comments/.json")response = Net::HTTP.get_response(uri)data = JSON.parse(response.body)data['data']['children'].each do |child|    puts child['data']['body']end