-
Notifications
You must be signed in to change notification settings - Fork 619
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
Default value for unknown Enum value #90
Comments
Good use case, Jackson can do it and we rely its feature |
@sandwwraith |
@avently Not yet |
This would be really useful. Does anyone know if this will be implemented? |
This is important for us too. Any other ways to do this? |
This would be a really appreciated feature! |
This is just to help others who need to solve this issue here and now: Bolinfest showed us how to do create a custom serializer here on issue #31 |
For those who need a solution here is a complete answer. |
If you are interested in even better forward compatibility of enums, I would recommend using a wrapper like this: https://github.com/bright/codified. I have been using it for a quite long time and it works beautifully. Feel free to let me know what you think about it 😊 |
Enabling |
I updated this example by @igrmk, and made it generic: https://gist.github.com/arberg/e20db05e018c61f37f1d274a254657c3 The code above annotates the enum-class with something like |
In order to be forward-compatible and support certain scenarios, it would be useful to have a way to specify a default value for a deserialized
Enum
field, if an unknown value is encountered. That way, if a new type is defined and being returned by remote APIs, apps already in production will work properly in the intermediate period before migration.Example:
would return a
Test(UNKNOWN)
when provided with the following json:{'status': 'PENDING'}
The text was updated successfully, but these errors were encountered: