JSON序列化:
var responseDict: [AnyHashable : Any]? = nil
if let anEncoding = responseString?.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue)) {
responseDict = try! JSONSerialization.jsonObject(with: anEncoding, options: .mutableContainers) as? [String : Any]
}
我在这个函数中传递这个 responseDict :
func apiClientDidFinishWithResponse(response: [AnyHashable : Any]? {
}
现在才意识到responseDict也可以是一个数组。我应该将responseDict保持为什么?Any
, [AnyHashable : Any]
, [[AnyHashable : Any]]
?