My JSON object looks like this:
{
"destination_addresses" : [ "Paris, France" ],
"origin_addresses" : [ "Amsterdam, Nederland" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "504 km",
"value" : 504203
},
"duration" : {
"text" : "4 uur 54 min.",
"value" : 17638
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
I will need the "504 km" value from distance. How can i do this?
One of the libraries that can parse JSON is superobject.
To get
rows.elements.distance
from your JSON, code would look like this:You can use the
DBXJSON
unit, included since Delphi 2010.Try this sample