-
-
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
JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES does not work for JsonAlias #1851
Comments
case 1: annotation at the property
case 2: annotation at the class level
case 3: annotation at the usage of the class containing the property
From those 3 variants, only the (3.) one works for me that it actually calls |
@pjungermann Thank you for digging deep into this. I'll see how to fix this. |
Ah. This may be documentation issue. So, first things first: when used as follows: public class A {
@JsonFormat(with = ACCEPT_CASE_INSENSITIVE_PROPERTIES)
private B b;
} effects apply to properties of value So, (1) does not and will not work the way expected here. (2) on the other hand is probably more like missing handling. It is possible to add per-class config overrides, which do work:
So there may be a missing piece here. |
Created #1886 as follow up to this, to potentially support (2) in future. |
I was trying to use
@JsonAlias("myAlias")
and@JsonFormat(with = {JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES})
at a property at version2.9.2
(bom) -- current latest jackson-databind version. Unfortunately this failed. Enabling it globally though worked fine. As far as I've checked it, it is related to #1232 which added support for case insensitive properties configured at properties rather than globally and #1029 adding support for@JsonAlias
(provided by FasterXML/jackson-annotations#116).My debugging lead me to the following:
BeanPropertyMap
gets created withcaseInsensitive = false
due to the global configuration at which the alias mapping gets setup case sensitiveBeanPropertyMap.withCaseInsensitivity
gets called with the config fromJsonFormat
BeanPropertyMap
by using the constructorBeanPropertyMap(BeanPropertyMap base, boolean caseInsensitive)
which just copies the case sensitive aliasMapping and aliasDef.BeanPropertyMap.find
converts the key to lower case due it being in the case insensitive state. As it does not find the property, it will continue at_find2
by passing_aliasMapping.get(key)
to_findWithAlias
etc. Neither of those check for the case insensitive state, the key is already in lower case but the mapping is still in it's original case sensitive form.This leads to that it works only for the property name itself, but not for it's alias names.
The text was updated successfully, but these errors were encountered: