I am trying to get the coordinates from a JSON file.
JSON File Structure:
{
"parkeerlocaties": [
{
"parkeerlocatie": {
"Locatie": "{\"type\":\"Point\",\"coordinates\":[4.9032801,52.3824545]}"
}
}
I can access the Locatie object and it returns the following:
{"type":"Point","coordinates":[4.9032801,52.3824545]}
But when I am trying to get the coordinates from the JSON file, I get undefined back.
Code:
$.getJSON(parkingUrl, function(parkingData) {
pData = parkingData.parkeerlocaties;
for (var x = 0; x < pData.length; x++ ) {
ploc = parkingData["parkeerlocaties"][x]["parkeerlocatie"]["Locatie"]["coordinates"];
console.log(ploc);
};
});
};
So, how can I get the coordinates from the JSON file?