-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Register a custom EnumSerializer to overwrite the default EnumSerializer #227
Comments
Thank you !!! :-) +1 |
First part of implementation; serializer registration works. |
Completed implementation; will be included in 2.3.0 when it is out (which will take a while, as dev only started). |
Awesome! Thank you Tatu @cowtowncoder ! :) |
No problem; thank you for the idea! |
Thank you @cowtowncoder ! |
I could really use this functionality but can't seem to figure out how. Is there any documentation or example code anywhere? |
@maxkremer Does |
@cowtowncoder yes it does. Sorry for the dumb question. Looking at the test code helped me to understand how this work. Thanks |
@maxkremer no problem; glad you figured it out. Documentation is not as well organized as it should be, so I can understand it not being obvious. |
Create a custom CustomEnumSerializer, and add it to a SimpleModule as following:
public class CustomEnumSerializer extends StdScalarSerializer{
//... custom code here
}
public class MySimpleModule extends SimpleModule{
public void setupModule(SetupContext context) {
addSerializer(Enum.class,new CustomEnumSerializer());
}
}
and finally objectMapper.registerModule(new MySimpleModule());
But, currently, the CustomEnumSerializer dose not overwrite the default one.
The text was updated successfully, but these errors were encountered: