我是SWIFT的新手,在从JSON文件中过滤空值并将其设置到Dictionary时遇到问题. 我从服务器收到空值的JSON响应,它使我的应用程序崩溃.
Here is JSON response:
"FirstName": "Anvar",
"LastName": "Azizov",
"Website": null,
"About": null,
I will be very appreciated for help to deal with it.
UPD1: At this moment I decided to do it in a next way:
if let jsonResult = responseObject as? [String: AnyObject] {
var jsonCleanDictionary = [String: AnyObject]()
for (key, value) in enumerate(jsonResult) {
if !(value.1 is NSNull) {
jsonCleanDictionary[value.0] = value.1
}
}
}