I am using google maps API, and getting the response from google. Just need to get distance "text" value, e.g. 57.6 mi and duration "text" value where it is "1 hour and 1 min" from JSON that gets returned.
{
"destination_addresses" : [ "blah blah" ],
"origin_addresses" : [ "some address" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "57.6 mi",
"value" : 92652
},
"duration" : {
"text" : "1 hour 1 min",
"value" : 3664
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
I have tried to parse it out by using dot notation and key-value pairs, but the deepest I could get is getting "rows" - which returned me object Object.
rowshas an array (of one element) inside it. so you probably needrows[0].elements[0].distance.text