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

Improvement - Allow JsonAnyGetter to be used in Map fields #2857

Closed
andrebrait opened this issue Sep 17, 2020 · 1 comment
Closed

Improvement - Allow JsonAnyGetter to be used in Map fields #2857

andrebrait opened this issue Sep 17, 2020 · 1 comment

Comments

@andrebrait
Copy link

Is your feature request related to a problem? Please describe.
Since @JsonAnySetter can be used in fields, I think it would make sense to also allow @JsonAnyGetter to be used in fields whose type is java.util.Map. I fail to see why it shouldn't be able to be used in fields just like @JsonAnySetter is. Considering @JsonAnyGetter only requires the method return type to be java.util.Map, it seems that it's quite intuitive to be able to annotate a field with it.

Describe the solution you'd like
To allow @JsonAnyGetter to be used in fields as well as methods returning java.util.Map.

Usage example
Something like this:

@JsonAnySetter
private final Map<String, Object> aMap = new HashMap<>();

@JsonAnyGetter
public Map<String, Object> getaMap() {
    return this.aMap;
}

could become:

@JsonAnySetter
@JsonAnyGetter
private final Map<String, Object> aMap = new HashMap<>();

Additional context
Opening this more as a request for comments. I might be able to implement this and submit a PR on a later date, if the idea gets approval.

@andrebrait andrebrait added the to-evaluate Issue that has been received but not yet evaluated label Sep 17, 2020
@andrebrait
Copy link
Author

For some reason, #1458 didn't show up in my previous query here. Closing this then.

@cowtowncoder cowtowncoder removed the to-evaluate Issue that has been received but not yet evaluated label Dec 9, 2020
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

2 participants