[英]Is there a jackson annotation to ignore a setter?
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?
我如何才能忽略非String参数方法?
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. 定义要使用的吸气剂。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.