I'm trying to parse complex JSON file in Swift 3. I'm having trouble with getting values. I found some sample code and tried to tweak it a bit but it doesn't work I currently get an error "Type "NSArray?" has no subscript members"... I'm not even sure this is the right way to do it. Attaching JSON screenshot any advice on how to properly parse it really appreciated.
Here's my current code:
let jsonResult = try JSONSerialization.jsonObject(with: urlContent, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject
let mainlistJson = jsonResult["mainlist"]as? NSArray
if let items = mainlistJson["items"] as? NSArray
{
for item in items {
if let description = item["description"]as? String {
print(description)
} } }