fastjson过滤字段属性
前端之家收集整理的这篇文章主要介绍了
fastjson过滤字段属性,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PropertyFilterfilter=
new
PropertyFilter(){
@H_
403_14@
public
boolean
apply(Objectsource,Stringname,Objectvalue){
if
(
"code"
.equals(name)||
"shengid"
.equals(name)){
return
false
;
}
true
;
}
};
SerializeWritersw=
SerializeWriter();
JSONSerializerserializer=
JSONSerializer(sw);
serializer.getPropertyFilters().add(filter);
serializer.write(cityList);
response.getWriter().write(sw.toString());
SimplePropertyPreFilterfilter=
SimplePropertyPreFilter(TTown.
class
,
"id"
"townname"
);
response.getWriter().write(JSONObject.toJSONString(townList,filter));