fastjson 序列化排除指定字段

在使用fastjson序列化时,没有使用的注解的情况下过滤不想要的字段

SimplePropertyPreFilter simplePropertyPreFilter = new SimplePropertyPreFilter();
simplePropertyPreFilter.getExcludes().add("password");

JSONObject userInfo = JSON.parseObject(JSON.toJSONBytes(principal, simplePropertyPreFilter));
System.out.println("userInfo = " + userInfo);

posted on 2024-04-23 11:11  luyifo  阅读(172)  评论(0)    收藏  举报

导航