I am trying to Parse a json. Casting to [String,AnyObject?] fails. while [String,AnyObject] succeeds
if let jsonDictionary = try! NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOptions.MutableContainers) as? Dictionary<String,AnyObject?> {
print(jsonDictionary["output"])
}
else {
print("Parsing Error")
}
The above parsing fails, while the below succeeds
if let jsonDictionary = try! NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOptions.MutableContainers) as? Dictionary<String,AnyObject> {
print(jsonDictionary["output"])
}
else {
print("Parsing Error")
}
I want to know why this happens.