Extracting information from JSON
Posted: 22 Nov 2019 10:57
I want to extract the trip duration from a Google Maps navigation request. The response is simple and I only need 1 value from it: the duration text.
How do I get to rows > elements > duration > text > "33 mins" in this example?
The solution is probably similar to this earlier answer I found but I can't figure out how to drill down into the deeper levels of the response.
How do I get to rows > elements > duration > text > "33 mins" in this example?
Code: Select all
{ "destination_addresses" : [ "Holloway, London N7 6PG, UK" ],
"origin_addresses" : [ "Westminster, London, UK" ],
"rows" : [
{ "elements" : [
{ "distance" : {
"text" : "9.0 km",
"value" : 8960
},
"duration" : {
"text" : "33 mins",
"value" : 1980
},
"status" : "OK"
} ] } ], "status" : "OK" }