打印JSON字符串过滤不需要打印的字段
testField是不需要打印的字段
public class testFilter implements PropertyPreFilter {
@Override
public boolean apply(JSONSerializer jsonSerializer, Object o, String s) {
return !s.equals("testField");
}
}
使用:
testFilter propertyFilter = new testFilter();
JSON.toJSONString(list, propertyFilter)