I have an external JSON-file. It looks like this:
{
"type":"FeatureCollection",
"totalFeatures":1,
"features":
[{
"type":"Feature",
"id":"asdf",
"geometry":null,
"properties":
{
"PARAM1":"19 16 11",
"PARAM2":"31 22 11",
"PARAM3":"12 10 7",
}
}],
"crs":null
}`
As I think "features" is an JSON-array and "properties" an object of this array. I stuck at trying to "push" the element "PARAM1" into another array in my JS-code. My attempt was to get the data via jQuery AJAX. It looks like this:
function (){
var arrPARAM1 = new Array ();
$.ajax({
async: false,
url: 'gew.json',
data: "",
accepts:'application/json',
dataType: 'json',
success: function(data) {
arrPARAM1.push(data.features);
}
})
console.log(arrPARAM1);
}
With arrPARAM1.push(data.features) I can "push" the whole array "features" into my JS-array. But I only want to have the element "PARAM1" from the object "properties". How can I get deeper (features --> properties --> PARAM1)?
Thanks for your attention!
SOLUTION:
arrPARAM1.push(data.features[0].properties.PARAM1);