I am accessing a CMS with a pre-baked JSON output and it uses the following data structure. I am struggling to get down into the nested collections to get the version or loop through the categories.
{
results: [
{
pageData: {
info: {
version: "1"
},
categories: [
{
name: "Cat 1"
},
{
name: "Cat 2"
}
]
}
}
]
}
Here is the code I was attempting to use. Any help is appreciated!
guard let json = json, let results = json["results"], let pageData = results["pageData"], let info = pageData["info"] as? [String:Int], let version = info["version"],
let categories = Category.getCategories(json: json) else {
self.completionParse(RequestResult.errorParsing, self.categoriesResult)
return
}