如何使用for循环与对象循环Restful Web服务

时间:2015-01-20 15:33:19

标签: javascript json

如何使用单个对象的for循环遍历Restfulwebserivice。我不想用于每个循环,所以我该怎么做。我无法使用

获取数据
for(var key in data) {
                    alert(data[key].hotel_geo_node.name);
             if(data.hasOwnProperty(key)){
               data[key].hotel_geo_node.name;
           }

}

这是api代码。

{
  "data": {
    "4325474491990470056": {
        "hotel_geo_node": {
            "name": "The Capitol", 
            "tags": {
                "hotel_chain_code": [
                    "nichendgrp"
                ], 
                "property_type": [
                    "Hotel"
                ], 
                "property_budget_category": [
                    "Luxury"
                ], 
                "others": [
                    "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"
                ]
            }, 
    }
 }

}

0 个答案:

没有答案