In Swift, NSJSONSerialization.JSONObjectWithData uses Optional(<null>) for null value in JSON. Is that possible to tell the parse to use nil instead (i.e., drop fields with null values because Swift Dictionary doesn't allow nil value)?
NSJSONSerialization uses NSNull objects, and that's what you're seeing; you can simply check for them by comparing to NSNull().
Optional() is an NSNull value. You can avoid error like this:
if !(myField is NSNull) {
//Whatever you want to do with myField when not null
} else {
//Whatever you want to do when myField is null
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With