首页 > 代码库 > list 转 jsonString 忽略字段

list 转 jsonString 忽略字段

 

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;

 

private SimplePropertyPreFilter filter = new SimplePropertyPreFilter();

filter.getExcludes().add("name1");     //忽略的字段
filter.getExcludes().add("name2");

String jsonString = JSON.toJSONString(list, filter);

 

list 转 jsonString 忽略字段