-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Deserialization of unknown value for enums does not yield default enum value #4403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ok, yes, I can reproduce: thank you for providing the sample project. The root cause: this happens because I'll have to see what we can do here. |
@dominik-henning In the meantime you may want to enable
to prevent use of index (number) values for |
Thank you @cowtowncoder for the hint. I enabled the feature and now it works like a charm. |
Good! I hope I can find other minor improvements but at least you can use configuration to avoid the problem. |
Ok, was able to add a minor improvement: will NOT consider Strings with leading Not quite as good as preventing (automatic) use of "Stringified" numbers, but thinking it helps. Will be in 2.17.0. |
Thanks @cowtowncoder , appreciate it ! |
Search before asking
Describe the bug
i have a class containing a field of an enum type. The data is fetched from an api that can add further possible enum values at any point. I want to guard my implementation by using the JsonEnumDefaultValue.
During the deserialization of an unknown value, instead of the annotated default, a different instance of this enum is returned.
Version Information
2.16
Reproduction
https://github.com/dominik-henning/jackson-databind-enum-deserialization-reproducer
i created a projected containing a test class which shows my usecase and setup.
Expected behavior
When an value is encountered which does not match to a annotated JsonProperty, i would expect that the JsonEnumDefaultValue is returned.
Additional context
The real world example is different, but the project boils the problem down to the bare minimum.
The text was updated successfully, but these errors were encountered: