默认的jackon行为似乎使用两个属性(getter和setter)和字段来序列化和反序列化为json.
我想使用这些字段作为序列化配置的规范来源,因此不希望jackson完全查看属性.
我可以使用注释在单个类的基础上执行此操作:
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
Run Code Online (Sandbox Code Playgroud)
但我不想把它放在每一堂课......
是否可以在全球范围内进行配置?喜欢在Object Mapper中加一些?
我定义了以下类
@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 …Run Code Online (Sandbox Code Playgroud)