Wrap
Wrap copied to clipboard
Added ability to fallback nil values
This is the reborn of #36, as it was closed and I think it is relevant. Some APIs require sending null
values for properties, this approach is interesting because keep the JSON clean and you can only override the ones you need.
Like:
struct Image: WrapCustomizable {
let name
let path: String?
fileprivate func fallbackValueForProperty(propertyNamed propertyName: String) -> Any? {
if propertyName == "path" {
return NSNull()
}
return nil
}
}
will wrap to a JSON like this:
{
"name": "image.jpg",
"path": null
}