I'm using the googlematrix api call, in below I mentioned the reponse.
Here is my code
let jsonObjects=responseObject as! NSDictionary
var data = jsonObjects.data(using: .utf8)!
if let parsedData = try? JSONSerialization.jsonObject(with: data) as! [String:Any] {
let language = parsedData["rows"] as! [String:Any]
print(language)
let field = language["elements"] as! [[String:Any]]
let name = field["distance"]!
let text = field["text"]!
print(text) // ==> Test1
}
I need to access the text and value from the below format in swift3.0
{
"destination_addresses" : [ "Chennai, Tamil Nadu, India" ],
"origin_addresses" : [ "Madurai, Tamil Nadu, India" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "488 km",
"value" : 487721
},
"duration" : {
"text" : "8 hours 32 mins",
"value" : 30690
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}