I'm trying to parse some json in Xcode that is basically a bunch of objects in an object. The json looks like this below.
{"TDOC": {
"assetType": "EQUITY",
"assetMainType": "EQUITY",
"cusip": "87918A105",
"symbol": "TDOC"}}
I am parsing it using the code below in Xcode using swift5
do {
if let json = try JSONSerialization.jsonObject(with: jData, options: []) as? [String: Any] {
if let pr = json["TDOC"] as? Array<Dictionary<String, Any>> {
for p in pr {
print(p["assetType"] ?? "")
}
}
}
} catch let err {
print(err.localizedDescription)
}
I'm trying to get the assetType value but when I run the code, nothing prints out to the console. When I debug, it seems like Xcode just skips right over my for in loop for that prints the assetType for some reason. Any help on this is appreciated.