杰克逊JSON Java类 - 字段是序列化多次 [英] Jackson JSON java class - fields are serialized multiple times
本文介绍了杰克逊JSON Java类 - 字段是序列化多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个下面的类定义
@JsonTypeName("PhotoSetUpdater")
public class PhotoSetUpdater {
@JsonProperty("Title")
private String title;
@JsonProperty("Caption")
private String caption;
@JsonProperty("Keywords")
private String[] keywords;
@JsonProperty("Categories")
private int[] categories;
@JsonProperty("CustomReference")
private String customReference; // new in version 1.1
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public String getCustomReference() {
return customReference;
}
public void setCustomReference(String customReference) {
this.customReference = customReference;
}
public void setKeywords(String[] keywords) {
this.keywords = keywords;
}
public String[] getKeywords() {
return keywords;
}
public void setCategories(int[] categories) {
this.categories = categories;
}
public int[] getCategories() {
return categories;
}
}
问题是,在我这个序列化类杰克逊JSON序列,字段在结果有效载荷insetrted两次入手一部以较低的字母,一个用大写字母:
The problem is that after I serialize this class with Jackson JSON serializer, the fields are insetrted twice in the result payload: one starting with lower letter, one with capital letter:
... {标题:AA,标题:AA,...}
... {"Caption":"aa","caption":"aa",...}
什么可能是错误的类型定义?
What may be wrong with type definition?
问候
推荐答案
尝试使用 @JsonAutoDetect(getterVisibility = Visibility.NONE)
的类。
这篇关于杰克逊JSON Java类 - 字段是序列化多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文