ObjectMapper-Plugin
ObjectMapper-Plugin copied to clipboard
Optional properties should be marked with `try?` instead of `try`
According to the documentation of the ObjectMapper
(https://github.com/Hearst-DD/ObjectMapper), and my own findings, optional properties should be parsed from JSON -> Model with try?
instead of just try
, else the whole init of the object will fail.
So e.g. if the name
property is optional then it should be:
init(map: Map) throws {
name = try? map.value("name") // optional
}