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

Allow use of @JsonFormat(with=JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) on Class #1886

Closed
cowtowncoder opened this issue Jan 12, 2018 · 11 comments
Milestone

Comments

@cowtowncoder
Copy link
Member

(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.

@cowtowncoder cowtowncoder changed the title Allow use of @JsonFormat(with=JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES } on Class Allow use of @JsonFormat(with=JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) on Class Jan 18, 2018
@JavierSegoviaCordoba
Copy link

JavierSegoviaCordoba commented Jul 26, 2018

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

@giltroymeren
Copy link

Issue still exists with version 2.9.0

@cowtowncoder
Copy link
Member Author

@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".

@cowtowncoder
Copy link
Member Author

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

@macfarla
Copy link

@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?

@cowtowncoder
Copy link
Member Author

@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.

@macfarla
Copy link

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

@kupci
Copy link
Member

kupci commented Nov 23, 2020

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

@cowtowncoder
Copy link
Member Author

cowtowncoder commented Nov 23, 2020

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.

@bipul-git
Copy link

is ACCEPT_CASE_INSENSITIVE_PROPERTIES working now for properties?

@cowtowncoder
Copy link
Member Author

@bipul-git It can be applied on individual properties with @JsonFormat, yes.

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

6 participants