What must be a rookie JSON/learning parsing error on my part: I expected my website of interest's json feed to return an array-of-dicionaries. I naively assumed if there was only a single entry, it would be a array with a single dictionary.
Doh! In the case where there is only a single dictionary to return, the api drops the array brackets and simply gives a dictionary. I'll confess to only lightly digging around for a JSON spec, but now I gather this is standard.
Perhaps this is a "best practices" question and perhaps it cannot be improved upon (cleaner? more elegant?)... but I am curious if in Swift 3 there is a nicer way to handle this array OR dictionary parse. Currently I am parsing it as follow:
if let record = json["record"] as? [[String : Any]] {
// Parse record as an array of dictionaries
} else if let record = json["record"] as? [String : Any] {
// Parse record as a dictionary
}