-
-
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
Add new factory method for creating custom EnumValues
to pass to EnumDeserializer
#2663
Comments
If a constructor is But adding an alternative factory method could be a slightly better choice. Perhaps one that would take I am open to other ideas, PRs. |
One quick thing that I can easily add, and have no problems with is to just add matching factory method in 2.11. I'd prefer keeping constructor private in this case for now, since class is already |
EnumValues
to pass to EnumDeserializer
Added 2 I think idea of supporting naming strategies in some form is good, and so although there are some open questions, will create a follow-up issue for that. |
The
com.fasterxml.jackson.databind.util.EnumValues
constructor is now private, which means that it isnot possible to create
EnumSerializer
instance with customEnumValues
. It should be at least protected, like is the case ofcom.fasterxml.jackson.databind.util.EnumResolver
used byEnumDeserializer
.I try to implement different strategy for serialization and deserialization of enums, simply to convert java SNAKE_CASE to more common in JSON camelCase and vice-versa. It is quite easy with
EnumDeserializer
, but in case ofEnumSerializer
it is not. I would like to just create new instance ofEnumSerializer
withEnumValues
instance build using different logic. Currently the only way (without reflection which I will use for the time being) is to cal theEnumValues#construct*
methods, which have hard-coded enum-to-string mapping logic.BTW. Consider adding casing strategy for enum serialization/deserialization as build-in jackson feature. For example in JSON.NET it is just a matter of passing approprate NamingStrategy to StringEnumConverter constructor.
The text was updated successfully, but these errors were encountered: