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...
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/d8dbfaba-1486-4235-9fef-ed646f60efa0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.