37,721
社区成员
发帖
与我相关
我的任务
分享
uri = '省略'
open(uri) do |http|
html_response = http.read
res_hash = JSON.parse(html_response)
#length_of_hash = res_hash["products"].length
#res_hash["products"].each {|product| printf("%-6s, %-6s, %-6s\n", product["discount"], product["updated_at"], product["id"])}
自己摸索出来了,不用那么麻烦 我感觉在Ruby里面你知道了变量的类型 再对它进行操作就简单了 用到了JSON.parse()
每天都进步一点 ,加油!