2

我定义了以下类

@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;
}

}

问题是,在我用 Jackson JSON 序列化程序序列化这个类之后,这些字段在结果负载中插入了两次:一个以小写字母开头,一个以大写字母开头:

... {“标题”:“aa”,“标题”:“aa”,...}

类型定义可能有什么问题?

问候

4

1 回答 1

6

尝试@JsonAutoDetect(getterVisibility=Visibility.NONE)在课堂上使用。

于 2011-09-26T16:02:37.897 回答