I have the following JSON response containing a JSON dictionary:
What I need is to only extract the 3 categories names (only 1 shown in my screenshot, namely "Drinks", but you can see at the very top a count of 3).
I tried the following, but always get nil returned.
func getMenuCategories() {
let headers = [
"Api-key": apiKey
]
let url = "https://xxxxxxxx/menu/categories"
Alamofire.request(.GET, url, headers: headers, encoding: .JSON)
.responseJSON { response in switch response.result {
case .Success(let JSON):
print("Success with JSON: \(JSON)")
let response = JSON as! NSDictionary
let categories1 = response.objectForKey("_embedded")! // always nil
let categories2 = response.objectForKey("categories")! // always nil
case .Failure(let error):
print("Request failed with error: \(error)")
}
}
}
I know I get a valid response because variable JSON
contains the whole response.
How can I search correctly?