gpt4 book ai didi

java - Jackson JSON java 类 - 字段被序列化多次

转载 作者:行者123 更新时间:2023-11-29 08:12:10 24 4
gpt4 key购买 nike

我定义了一个类

@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",...}

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

问候

最佳答案

尝试在类上使用 @JsonAutoDetect(getterVisibility=Visibility.NONE)

关于java - Jackson JSON java 类 - 字段被序列化多次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7557397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com