java对象转JSON时排除掉该对象中的特殊属性

来源:互联网 发布:golang java 对比 编辑:程序博客网 时间:2024/05/22 17:38

  ProjectApply pa=projectApplyService.getProjectApplyById(id);
  JsonConfig jsonConfig = new JsonConfig();
  jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
  jsonConfig.registerJsonValueProcessor(Date.class,new JsonDateValueProcessor());
  jsonConfig.setExcludes(new String[] { "projectProperty", "projectType" });
  JSONObject jsonObject=JSONObject.fromObject(pa, jsonConfig);
  ActionUtil.write(jsonObject.toString());
0 0