This behavior is a regression in 2.2.5. Works as expected in 2.2.4
{
"num": null,
}
struct Model: Mappable {
var num: Int = -1
init(_ map: Map) {
num <- map["num"]
}
}
let repo = Mapper< Model >().map(myJSONDictionary)
I exepected something like:
Repo(num: -1)
Repo(num: 0)
It's hard for me to understand if this is intended behavior or not. However, as a workaround you can do:
num <- map["num", ignoreNil: true]
Most helpful comment
It's hard for me to understand if this is intended behavior or not. However, as a workaround you can do: