Jackson-databind: Allow use of `@JsonFormat(with=JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)` on Class

Created on 12 Jan 2018  路  9Comments  路  Source: FasterXML/jackson-databind

(note: follow-up from #1851)

Currently @JsonFormat features, and specifically Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, does not apply if annotated via class. Like:

    @JsonFormat(with={ JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES })
    static class Role {
        public String ID;
        public String Name;
    }

whereas similar setting with mapper.configOverrides(class) does work.

It would probably make sense to allow annotation on class too, having lower precedence than config override, but higher than general one.

Most helpful comment

It isn't working for me (class or properties). If I create a custom mapper, it works.

How can I use this annotation on a property? I am using the last version of Jackson @cowtowncoder

All 9 comments

It isn't working for me (class or properties). If I create a custom mapper, it works.

How can I use this annotation on a property? I am using the last version of Jackson @cowtowncoder

Issue still exists with version 2.9.0

@JavierSegoviaCordoba @giltroymeren I am confused wrt your comments: this is an open issue, not marked as fixed, so how would it not be an issue any more? There is no need to add markers for "still not working".

Looking into implementing this for 2.12.0, next on my "hopefully simple to do" list.

@cowtowncoder looking closer at this it looks like you've added support at the class level but not at the property level, is that right? And if so, do you plan to add property level support?

@macfarla No, I don't think there is support for just one case-insensitive property, and there are no plans to do that.
You can file a new request if you want, in case someone had time and interest to implement it.

Thanks @cowtowncoder I have found another way to do what I need :)

@macfarla Just in case others have same issue, the JsonAlias solved the issue (in referenced bug) for you?

Ah, yes, @JsonAlias is good to mention here.

And as a sidenote: the reason for no support for single-property case-insensitivity is the technical implementation: lookup for all properties is via data structure that does either strict, or case-insensitive. So there is no way to distinguish this on per-property basis, as of yet.

Was this page helpful?
0 / 5 - 0 ratings