Skip to content
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

Case insensitive enum deserialization feature #1313

Closed
yissachar opened this issue Jul 26, 2016 · 5 comments
Closed

Case insensitive enum deserialization feature #1313

yissachar opened this issue Jul 26, 2016 · 5 comments

Comments

@yissachar
Copy link

Enums are only properly deserialized if the value is uppercase. We don't want to force all clients to have to manipulate their data into uppercase, so we would like to accept a String case-insensitively and have it be deserialized into the correct enum.

Others have encountered this issue and there are various solutions for achieving this effect.

I think this feature is used often enough that it warrants being added to the core, so that we could simply do something like:

mapper.configure(DeserializationFeature.READ_ENUMS_CASE_INSENSITIVELY, true);

Instead of having to search up the solution each time we encounter this issue.

@cowtowncoder
Copy link
Member

Sounds like possibly something to support, even thought it sort of goes against grain of JSON which is case-sensitive.

Not 100% sure what the best way is, since use of DeserializationFeature has its benefits and drawbacks (mostly this is kind of specific setting).
One alternative might be to introduce a new flag to @JsonFomat, caseSensitive, since then it could be added to properties as well.
On the other hand, DeserializationFeature could already also be applied via @JsonFormat, so perhaps dedicated feature would be ok.

@chethanbandi
Copy link

+1

@AnaEliza
Copy link
Contributor

@cowtowncoder I'd like to help you fix it. Can I have permission to create a branch?

@cowtowncoder
Copy link
Member

@AnaEliza the usual way is to do a fork, for which you do not need extra access.

cowtowncoder added a commit that referenced this issue Feb 23, 2017
Issue #1313: New IgnoreCase feature to deserialize enums
@cowtowncoder
Copy link
Member

Fixed via #1520.

cowtowncoder added a commit that referenced this issue Feb 23, 2017
…rty allowance (or not) of case-insensitivity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants