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

Support null-valued Map fields with "any setter" #3559

Closed
cowtowncoder opened this issue Aug 1, 2022 · 0 comments
Closed

Support null-valued Map fields with "any setter" #3559

cowtowncoder opened this issue Aug 1, 2022 · 0 comments
Milestone

Comments

@cowtowncoder
Copy link
Member

Currently it is not possible to have declaration like this:

    private static class JsonAnySetterOnMap {
        @JsonAnySetter
        public Map<String, String> other;
    }

since "any setter" handler cannot instantiate a Map: instead, one has to use:

    private static class JsonAnySetterOnMap {
        @JsonAnySetter
        public Map<String, String> other = new HashMap<>();
    }

In general this may not be an easily solvable problem; however, for a reasonable set of common, standard types,
there is class JDKValueInstantiators which does provide ability to construct instances. In case of Maps it covers:

  • HashMap
  • LinkedHashMap

(plus we can use defaulting for plain Map).

So let's see if we can add initialization; and in case no match found, throw an actual exception to indicate the problem instead of current behavior, quietly failing.

@cowtowncoder cowtowncoder added to-evaluate Issue that has been received but not yet evaluated 2.14 and removed to-evaluate Issue that has been received but not yet evaluated labels Aug 1, 2022
@cowtowncoder cowtowncoder modified the milestones: 2.10.0, 2.14.0 Aug 1, 2022
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

1 participant