I am trying to deserialize a JSON object stored in CouchDb using Jackson. This object must be deserialized in pojo, which contains overloaded methods. When I try to retrieve an object from the couch and do deserialization, I get the following exception:
org.ektorp.DbAccessException: org.codehaus.jackson.map.JsonMappingException: Conflicting setter definitions for the multiplier property: com.db.commodities.framework.sdos.model.security.EqOpt # setMultiplier (1 params) vs com.db .commodities.framework.sdos.model.security.EqOpt # setMultiplier (1 PARAMS)
I tried to annotate the installer that Jackson would like to use, but it looks like it didn't work.
@JsonProperty("multiplier") public void setMultiplier(SDOSAttribute multiplier) { this.multiplier = multiplier; } public void setMultiplier(double multiplier) { this.multiplier.setValue(String.valueOf(multiplier)); }
How to configure Jackson to properly deserialize using a specific method? Or am I approaching this problem incorrectly?
EDIT:
I made the following changes. It seems to work, but a little uglier. If anyone has a better way to do this, feel free to share, and I will happily agree.
@JsonProperty("multiplier") protected void setMultiplierAttribute(SDOSAttribute multiplier) { this.multiplier = multiplier; } @JsonIgnore public void setMultiplier(double multiplier) { this.multiplier.setValue(String.valueOf(multiplier)); }
java json jackson
gregwhitaker Jun 14 2018-11-11T00: 00Z
source share