I have an attribute that has two setters.
private boolean boolValue;
public void setBoolValue(boolean value) {
this.boolvalue = value;
}
public void setBoolValue(String value) {
this.boolValue = somemethod(value); // convert String to boolean
}
jackson won't deserialize with two setters. How can I get it to ignore the non String parameter method?
You can use
@JsonSetter
to set the setter you want to use.
Or
@JsonIgnore
on all the other setters except the one you want to use.
If you have multiple getters use
@JsonProperty
to define the getter to be used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.