2

Possible Duplicate:
I have a nested data structure / JSON, how can I access a specific value?

My Json response looks like this:

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

How can I just retrieve the referenceid value? I've searched and searched... tried all sorts of things but I can only return a "undefined".

Thanks

edit:

Forgot my other code:-

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);

});

}

Community
  • 1
  • 1
jaminben
  • 149
  • 2
  • 6
  • 15

1 Answers1

3

like this:

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

alert(a[0].referenceid);
jotik
  • 17,044
  • 13
  • 58
  • 123
Viren Rajput
  • 5,426
  • 5
  • 30
  • 41