I'm hoping someone can help me get the following getJson call going. I want to retrieve all the names which are buried in under features.attributes.NAME. See the sample json
{
"objectIdFieldName": "FID",
"globalIdFieldName": "",
"geometryType": "esriGeometryPolygon",
"spatialReference": {},
"fields": [],
"features": [
{
"attributes": {
"NAME": "ST. JOHNS"
}
},
{
"attributes": {
"NAME": "HAYDEN ISLAND"
}
}
]
}
Using jquery I'm currently trying something like this to create a blank array and push the names into it.
$.getJSON("url/myjson", function(data) {
items = [];
$.each( data, function(i) {
items.push(data.features.attributes.NAME);
});
});
The error I'm getting at the moment says Cannot read property 'NAME' of undefined.