过滤 Json 数据

2021-03-01  本文已影响0人  happyJared

@JsonIgnoreProperties:作用在类上

// 生成 json 时将 userRoles 属性过滤
@JsonIgnoreProperties({"userRoles"})
public class User {
    private String userName;
    private String fullName;
    private String password;
    private List<UserRole> userRoles = new ArrayList<>();
}

@JsonIgnore: 作用于类属性

public class User {
    private String userName;
    private String fullName;
    private String password;
   // 生成 json 时将 userRoles 属性过滤
    @JsonIgnore
    private List<UserRole> userRoles = new ArrayList<>();
}
上一篇 下一篇

猜你喜欢

热点阅读