spring boot Jackson忽略字段不序列化字段

时间:2025-03-17 08:16:44

使用JsonIgnoreProperties注解忽略多个字段

 

在jackSon中使用@JsonIgnoreProperties来忽略字段

 

@JsonIgnoreProperties({ "summary", "author" })
public class ArticleIgnoreProperties {

	private String title;
	private String summary;
	private String content;
	private String author;

	// 省略getter、setter方法

	@Override
	public String toString() {
		return "ArticleIgnoreProperties [title=" + title + ", summary=" + summary + ", content=" + content + ", author="
		        + author + "]";
	}

}

 

参考/zhanjia/article/details/108937875