-
Notifications
You must be signed in to change notification settings - Fork 657
Open
Labels
Description
When deserializing enum values, it would be useful to specify a fallback value, in case a remote API introduces a new value for the enum.
Example:
enum class Color {
Red,
Green,
@FallbackEnumValue
Unknown,
}
data class Scarf(val colors: List<Color>)
Then, the following JSON:
{ "colors": ["Green", "Blue", "Red"] }
Would result in:
Scarf(listOf(Green, Unknown, Red))
Another use case would be an API returning an enum with many possible values, where the client only cares about a subset of them, and would like to consider all other as a single "Other" value.
This is supported in Jackson as @JsonEnumDefaultValue
.
There was a similar issue #90, but it asked for the ability to use the default value as declared on the use site of the enum, which is different and not applicable to the above example.
WarningImHack3r and LouisCAD