我有这种格式的数据:
{"values"=>
[
{"updateKey"=>"UNIU-16268324-5608633092144111616-SHARE",
"updateComments"=>{"_start"=>1,
"values"=>[{"comment"=>"Sample test this is mike testing.",
"person"=>{"siteStandardProfileRequest"=>{"url"=>"http://www.linkedin.com/profile?viewProfile=&key=116654056&authToken=xVLh&authType=name&trk=api*a140290*s148640*"},
"lastName"=>"DeLorenzo",
"headline"=>"--",
"id"=>"QM86-RIKjb",
"pictureUrl"=>"http://media.linkedin.com/mpr/mprx/0_OurBLnHMma92b4U4pecXLq2MuW8aFOo4ywXHLqEbPuNO4sjZtEhUwNOWCFhAkJIq07-WoP4V_Zqg", "firstName"=>"Jennifer",
"apiStandardProfileRequest"=>{"url"=>"http://api.linkedin.com/v1/people/QM86-RIKjb", "headers"=>{"values"=>
[{"name"=>"x-li-auth-token",
"value"=>"name:xVLh"}],
"_total"=>1}}},
"timestamp"=>1337202768000,
"sequenceNumber"=>1,
"id"=>80942976},
{"comment"=>"123",
"person"=>{"siteStandardProfileRequest"=>{"url"=>"http://www.linkedin.com/profile?viewProfile=&key=70292133&authToken=wEAo&authType=name&trk=api*a140290*s148640*"}, "lastName"=>"Kartsovnyk", "headline"=>"Snr Software Developer", "id"=>"7-32mNn-Ob", "pictureUrl"=>"http://media.linkedin.com/mpr/mprx/0_xjj5WPXU6fCjCExLjUa9WA69XWNS
我要做的是遍历 updateComments 并获取该用户的每个“id”属性。
这是我到目前为止所拥有的:
if linked_in_updates.values.updateComments.is_a?(Hash)
linked_in_updates.each { |key, value|
some_value = key
}
end
我正在尝试使用以下方法提取作为 updateComments 的哈希:linked_in_updates.values.updateComments 但我收到如下错误:
NoMethodError: undefined method `updateComments' for #<Array:0x13228fc20>
知道我做错了什么吗?