您正在尝试遍历
data,这是一个哈希,而不是一个列表。您需要通过以下方式从JSON对象中获取children数组:
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


