开发者社区 问答 正文

有关于 json值获取 问题

{
    "response":{
        "110":{
            "location":null,
            "name":"报警电话",
            "type":"poi"
        }
    },
    "responseHeader":{
        "status":200,
        "time":1452220774806,
        "version":"1.1.0"
    }
}

上述的json如何快速获取location、name、type的值,110表示的是用户输入的号码,是会变化的。

展开
收起
爵霸 2016-03-05 08:43:21 1693 分享 版权
1 条回答
写回答
取消 提交回答
  • 变与不变并没有区别。
    变就定义成变量就行了。

    var foo = 110; // 或者从用户那儿取到这个数据
    
    var location = response[foo].location;
    var name = response[foo].name;
    var type = response[foo].type;
    2019-07-17 18:52:51
    赞同 展开评论
问答分类:
问答标签:
问答地址: