I simply want to pinpoint a specific value out of a JSON array.
Sample of JSON array:
{
"00002": {
"Job Number": "00002",
"Company": "Corporate",
"Supervisor": "Great Person",
"Date Input": "2016-01-07"
},
"00003": {
"Job Number": "00003",
"Company": "SmallGuy",
"Supervisor": "Awful Person",
"Date Input": "2012-03-05"
}
}
This works in Javascript:
alert(javascript_array["00002"].Company);
But I want use a dynamic variable to call a record, like this:
var my_variable = 00002;
//OR I've tried:
var my_variable = "'"+00002+"'";
alert(javascript_array[my_variable].Company); //DOES NOT WORK. UNDEFINED??
No matter what I do, I can't use a variable mid-array call.
Help please!
my_variable? Works here: jsfiddle.net/wsq3yj30var my_variable = "00002", you are adding unneeded quotes ("'00002'"), which is why it can't find it.String, else, itstoString()value will be used as key name.