json出现$ref 重复引用问题

//在controller 中, 引用该方法,返回一个json对象
Map<String, Object> data = 
   customService.loadindividualStyle(searchMap);(该方法中 for 循环封装实体类, 重复封装了一个 对象,)
遇到问题, 返回的json对象出现$ref{对象,地址值,}

解决方法:!!!
//转换json对象,防止重复引用
String json = JSON.toJSONString(data,SerializerFeature.DisableCircularReferenceDetect);
JSONObject jsStr = JSONObject.parseObject(json);
 
//最后将json对象返回 
return new DzResult(200,"",jsStr);

  问题解决!! 不在出现对象重复引用问题

猜你喜欢

转载自blog.csdn.net/qq_24641227/article/details/82951969