Hi all,
I'm experiencing some jon fields duplication problems using @JsonAnyGetter annotation.
If I have a class with a name attribute and its getter and a map annotated with @JsonAnyGetter containing an entry having "name" as key, resulting json has two fields "name".
Consider this simple and incomplete snippet:
public class JsonObject {
private String name;
private final Map<String, Object> map = new HashMap<>();
public String getName() {
return (String) get("name");
}
@JsonAnyGetter
public Map<String, Object> get() {
return map;
}
@JsonAnySetter
public Object put(String key, Object value) {
return map.put(key, value);
}
}
Is there a way to ignore my getName() method or is there a way to remove the duplication?
Please consider that my example is very simple, my real case is more complex, I have some classes which extend a class containing the map, children classes contain specific getter and setter (e.g. getName() setName()) which work directly with the map attribute present in parent class.
Thank you very much, best regards
Inserisci qui il codice...