从Json响应中获取单个值

时间:2013-01-19 12:19:16

标签: jquery

  

可能重复:
  I have a nested data structure / JSON, how can I access a specific value?

我的Json回复如下:

[{"referenceid":"999","firstname":"Firstname","middlename":"Middlename","lastname":"Surname","shortlisted":"0"}]

如何检索referenceid值?我搜索过并搜索过...尝试了各种各样的事情,但我只能返回“未定义”。

由于

编辑:

忘记我的其他代码: -

function populateFormData() {

var mxKey = $.now();

$.get("\\web\\php\\somesite\\phpData.php?mxKey" + mxKey, function(applicationData) {

    console.log("Application Data: " + applicationData);

    var jsonData = JSON.parse(applicationData);

    console.log("Json Parse Data: " + jsonData);

});

}

1 个答案:

答案 0 :(得分:3)

像这样:

var a = [{
  "referenceid": "999",
  "firstname": "Firstname",
  "middlename": "Middlename",
  "lastname": "Surname",
  "shortlisted": "0"
}];

alert(a[0].referenceid);