如何从这个json数据中获取城市?

时间:2014-09-03 04:42:18

标签: json

{
    "useraddresses":{
        "address_id":"46",
        "user_id":"89919",
        "address_title":"test",
        "address_type":"1",
        "street_address":"34",
        "region":"Aquitaine",
        "cp":"01100",
        "country":"FR",
        "email":"tes@gmail.com",
        "tel1":"12345",
        "tel2":"12345",
        "city":"Apremont",
        "coorx":"0",
        "coory":"0",
        "gender":null,
        "compliment1":null,
        "compliment2":null,
        "flag":"0",
        "additional_info":null
    }
}

2 个答案:

答案 0 :(得分:0)

//By using jquery json parser

var obj = $.parseJSON('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(obj['jobtitel']);

//By using javasript json parser
var t = JSON.parse('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(t['jobtitel'])

http://www.mkyong.com/javascript/how-to-access-json-object-in-javascript/

答案 1 :(得分:0)

var JSONObj = { "useraddresses":{ "address_id":"46", "user_id":"89919", "address_title":"test", "address_type":"1", "street_address":"34", "region":"Aquitaine", "cp":"01100", "country":"FR", "email":"tes@gmail.com", "tel1":"12345", "tel2":"12345", "city":"Apremont", "coorx":"0", "coory":"0", "gender":null, "compliment1":null, "compliment2":null, "flag":"0", "additional_info":null } };
 alert(JSONObj.useraddresses.city);