在任何时间点,我将只设置一个setter方法,但JsonProperty名称应该相同。当我编译这个时,我得到一个异常。如何为两者设置相同的名称。?如何使用相同的@jsonproperty名称int以下示例?
public String getType() {
return type;
}
@JsonProperty("Json")
public void setType(String type) {
this.type = type;
}
public List<TwoDArrayItem> getItems() {
return items;
}
@JsonProperty("Json")
public void setItems(List<TwoDArrayItem> items) {
this.items = items;
}
为什么你隐瞒编译器错误的细节?这将是相关的,除非你喜欢猜测游戏。 – 2013-05-08 05:27:35
那么你期望杰克逊在任何时候知道要序列化哪一个?毕竟,'null'是一个完美的序列化值。 – 2013-05-08 05:29:20
我得到这个例外。 com.fasterxml.jackson.databind.JsonMappingException:属性“Json”的getter定义冲突:在两个setter方法中,一个在时间上是空的。 – Naveen 2013-05-08 05:34:49