I'm pretty new to JSON and unsure how to access the arrays within my result. I want to store the coordinates in 3 seperate javascript arrays. How do I access the coordinates?
Here is my ajax:
$.ajax({
url: 'urlhere.php',
type: "GET",
dataType: "jsonp",
success: function (data) {
}
});
data.routes
gets me close, but I'm struggling to access data.routes.route_parts.coordinates
, if that makes sense:
{
"request_time": "2016-08-02T20:32:31+01:00",
"routes": [
{
"duration": "01:46:00",
"route_parts": [
{
"mode": "foot",
"from_point_name": "specified point",
"to_point_name": "ABC",
"destination": "",
"line_name": "",
"duration": "00:05:00",
"departure_time": "06:12",
"arrival_time": "06:17",
"coordinates": [
[
-12.72212,
53.64521
],
[
-12.72212,
53.6452
]
]
},
{
"mode": "bus",
"line_name": "113",
"duration": "00:28:00",
"departure_time": "06:17",
"arrival_time": "06:45",
"coordinates": [
[
-12.72419,
53.64403
],
[
-12.72412,
53.64405
],
[
-12.72412,
53.64405
],
[
-12.48062,
53.70897
],
[
-12.48051,
53.70881
]
]
},
{
"mode": "foot",
"duration": "00:07:00",
"departure_time": "08:53",
"arrival_time": "09:00",
"coordinates": [
[
-12.48042,
53.70883
],
[
-12.4805,
53.7088
],
[
-12.48033,
53.70857
]
]
}
],
"departure_time": "06:56",
"departure_date": "2016-08-03",
"arrival_time": "09:00",
"arrival_date": "2016-08-03"
}
]
}