Json.toJson 有没有根据对象字段的某个注解信息判定是否输出呢?
3 回复
String json = "{name:'nutz', age:12, address:[{area:1,name:'abc'}, {area:2,name:'123'}]}";
Object obj = Json.fromJson(json);
List list = new ArrayList();
list.add("age");
list.add("address[].area");
Object newobj = Mapl.excludeFilter(obj, list);
String json = Json.toJson(newobj)
bean 里放一个
static final List EXCLUDE =Arrays.asList("age","address[].area");
使用时
String json = "{name:'nutz', age:12, address:[{area:1,name:'abc'}, {area:2,name:'123'}]}";
MyBean obj = Json.fromJson(MyBean.clas,json);
Object newobj = Mapl.excludeFilter(obj,obj.EXCLUDE);
String json = Json.toJson(newobj)
添加回复
请先登陆