我正在进行一个返回以下响应的 API 调用:
{
"firstName": "",
"lastName": "",
"address": {
"type": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zipCode": "",
"country": ""
},
"race": "",
"phones": [
{
"type": "",
"number": ""
}
],
"joinDate": ""
}
如何访问数组中的"number"
变量"phones"
?我试过这个:
@phone = response["phones"].map { |s| s["number"] }
puts phone
但我没有运气。我正在使用 Ruby 1.9.3。