项目数我有一个JSON对象如下:JSON - 伯爵在Ruby中
jsonobject = {
"fruits": [
{
"name": "A",
"uri": "a.com"
},
{
"name": "B",
"uri": "b.com"
}
],
"trees": [
{
"name": "t1",
"uri": "t1.com",
"status": null
},
{
"name": "t2",
"uri": "t2.com",
"status": null
}
]
}
如何获得在Ruby中的树/水果的数量?
您可以清楚说明此代码的上下文吗? – Ursus
我得到这个json对象作为HTTP GET请求的输出。现在我只想计算“水果”和“树木”内的物品数量。我使用这些名称而不是实际获得的信息。只是不透露信息。你现在可以帮忙吗? –
'json = JSON.parse(jsonobject)[“trees”]。size'? – Kris