Skip to content

Use default when passed value is null #246

@dri94

Description

@dri94

When deserializing a json and we get a null value passed down, an annotation/setting should be allowed to instead use the default value. The following scenario will fail if deserialize because it is looking for a non-null value

{ 
"name": "john",
"number": null
}

data class Person(val name: String = "", val number: String ="")

If we had an annotation that specified to use default if null, the the following would deserialize correctly using the default value.

{ 
"name": "john",
"number": null
}

data class Person(val name: String = "", @UseDefault val number: String ="")

If this exists then please point me to the documentation :) Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions