-
-
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
Adding a Case Insensitive DeserializationFeature #568
Conversation
…erXML#566 in jackson-databind.
Ok, one question here: would this just basically lower-case expected names, but not change actual incoming names -- that is, work for case where incoming JSON names are all-lowercase (possibly by expecting or configuring Also: one practical note on features, something I forgot to mention earlier: all |
It leaves all names unchanged. The only change is in the bucketing key in BeanPropertyMap - so all values external to BeanPropertyMap remain the same. It really only affects the find method. How would you like me to update this pull request with the change to make it a MapperFeature? |
Oh yes. I did actually miss the specific line where incoming key is lower-cased. My bad. |
I think you can simply modify your forked branch, commit, push, and it should update. |
Seems to be the case, I'll do that shortly. Thanks for the pointers! |
… I should have followed the pattern from _defaultViewInclusion.
Thank you in advance for this contribution! The next practical thing (the first and last part of The Process) is that we need a Contributor License Agreement (CLA): https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf filled, signed, scanned and sent to Besides this; one thing I was wondering was whether it might make sense to allow per-type (Class) annotation to note that handling of a specific type should use case-sensitive/case-insensitive handling. This would be in addition to global setting which we could implement using same mechanism, and only overridden by annotation on per-class basis. |
I definitely wanted to get to an annotation based approach for this. The primary problem with the annotation approach as I saw it was that the BeanPropertyMap was being built in the build() method which didn't have easy access to any annotation or configuration context. The comment on line 339 effectively says the same thing. |
Although the resulting JsonDeserializer will eventually have its deserialize method called with the DeserializationContext - which would allow us to override the case insensitivity settings as needed. |
Ok, right. It is true that necessary contextual information will not yet be available at time of construction. So this would have to come via On plus side, this would allow per-property case-insensitivity, not just per-class. Not sure this matters a lot, but it may help in cases where external types are referenced. |
Looks like we could use As to annotation to use; while Besides annotation itself, there's then need to add a method in |
My thought around Converter is that I don't really want the bean property names or incoming property names to be converted - I want them as is. I just want the comparison logic to accept the differences in case. Which is why I've stayed away from all manner of converters. It feels like either a whole new annotation or add a property to @JsonNaming(caseSensitive=false) or something to that effect. Do you agree that the names should be left as is? That approach is really what I'd like to see (and would expect) from an implementation such as this. Modifying values just seems so side-effecty. I wouldn't expect to see my beautiful property names all mangled in debug (or on serialization). Thoughts? |
After thinking about it more, my objection to conversion stems from the fact that I really just want to change the comparison/matching behavior. The naming of the properties themselves is orthogonal to the comparison behavior and I don't want to conflate the two. |
By converter I simply meant a mechanism for doing what pull request is already doing -- that is, converting things on-the-fly, but solely for purpose of matching. That is, it would NOT change names accessed from The reason why I would prefer I can see why name 'converter', and use of |
On comparison: if there was an efficient way to plug different comparison, it could be an alternative. But this is where I actually do not see a good alternative; linear search over N/2 names, then doing comparison is rather inefficient. Because of this, canonicalizing bean property names once, and canonicalizing name used for lookup seems like a reasonable way to go. |
@mressler Ok sorry for the slow follow-up here. One thing I realized is that use of One way to change this would be to change it to be a And I think I got the CLA. So I can go ahead, merge this, and modify as mentioned above. |
Adding a Case Insensitive DeserializationFeature
Ah! Should have re-read my comments. You had already addressed feature part! Awesome. Thank you again -- this is something that should be quite valuable for many users. |
Quite welcome, thanks for the great library!
|
Added case insensitivity as a DeserializationFeature. Will close #566 in jackson-databind.