1. 程式人生 > >list 轉 jsonString 忽略字段

list 轉 jsonString 忽略字段

per prefilter simple .get alibaba filter .json exclude json

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 忽略字段