【发布时间】:2015-01-19 17:38:52
【问题描述】:
如何使用带有单个对象的 for 循环遍历 Restfulweb 服务。而且我不想为每个循环使用,所以我该怎么做。我无法使用
获取数据 for(var key in data) {
alert(data[key].hotel_geo_node.name);
if(data.hasOwnProperty(key)){
}
这里是 api { “数据”: { “4325474491990470056”:{ “hotel_geo_node”:{ "name": "国会大厦", “标签”:{ “hotel_chain_code”:[ “nichendgrp” ], “财产类型”: [ “酒店” ], “property_budget_category”:[ “奢华” ], “其他”: [ "goibibo_hotel" ] },
},
"4325474491990470057": {
"hotel_geo_node": {
"name": "The Capitol",
"tags": {
"hotel_chain_code": [
"nichendgrp"
],
"property_type": [
"Hotel"
],
"property_budget_category": [
"Luxury"
],
"others": [
"goibibo_hotel"
]
},
},
"4325474491990470058": {
"hotel_geo_node": {
"name": "The Capitol",
"tags": {
"hotel_chain_code": [
"nichendgrp"
],
"property_type": [
"Hotel"
],
"property_budget_category": [
"Luxury"
],
"others": [
"goibibo_hotel"
]
},
}
}
}
【问题讨论】:
标签: javascript json for-loop