I consider myself to be at an intermediate level in JavaScript, but I've hit a roadblock when trying to access the key in a JSON message that is returned to me.
My code is dynamic, so I need to pass the key into the query. For example:
After running this JSON query:
var data = JSON.parse([some url]);
I receive the following formatted data:
{
"Status":"Success",
"IsValidSession":"False",
"ErrorMessage":"Success",
"CUSTOM_MARKER_ID_FROM_DCVIEW1":
[
{
"PlaceID":"CUSTOM_MARKER_ID_FROM_DCVIEW",
"IsVisible":"true",
"Message":"An e-stop has been pulled.",
"ImageName":"alert.png",
"IsPulse":"No"
}
]
}
The key "CUSTOM_MARKER_ID_FROM_DCVIEW1" needs to be variable when querying "data." I can't hard-code it like this:
$.each(data.CUSTOM_MARKER_ID_FROM_DCVIEW1, function(i, value) {/*do some stuff*/});
Is there a way to pass in a variable after "data."?
Any assistance would be greatly appreciated. Thank you!