I am getting this json from a url, the return JSON is:
[{\"id\":1,\"name\":\"Mary\"},{\"id\":2,\"name\":\"John\"}]
I want to display the n
The variable jsonResult
is an array of dictionaries, so you can loop through the array with
for anItem in jsonResult as! [Dictionary] { // or [[String:AnyObject]]
let personName = anItem["name"] as! String
let personID = anItem["id"] as! Int
// do something with personName and personID
}
In Swift 3 the unspecified JSON type has been changed to Any
for anItem in jsonResult as! [Dictionary] { ... // or [[String:Any]]