Just when I think I have mastered identifying an element in an object, I come across a situation where I am unable to obtain the desired value.
This part is successful and the data returned is accurate: A map click triggers the function MapClick(queryResults) which returns the following JSON object (this has been truncated for readability but it is properly formatted):
dojo.io.script.jsonp_dojoIoScript19._jsonpCallback({
"results": [
{
"layerId": 5,
"layerName": "Building",
"value": "Name of item clicked",
"displayFieldName": "name",
"attributes": {
"ID": "123",
"name": "Name of item clicked",
"Variable1": "Some bit of information",
"Variable2": "Some other bit of information",
...
...
All I am attempting to do is retrieve either the results[0].value
OR results[0].attributes.name
, which should return "Name of item clicked" in this example. The layerId, layerName, value, and displayFieldName are commonly accessed data that are returned, but the same information can also be found within the attributes.
I have attempted
console.log(results[1].attributes.name);
and console.log(results)
without success.