1. DisableCircularReferenceDetect来禁止循环引用检测:
2. JSON.toJSONString(..., SerializerFeature.DisableCircularReferenceDetect)
3.项目中遇到问题的源代码:

// 查询所有的订单
@ResponseBody
@RequestMapping("queryAllOrderList")
public void queryAllOrderList(HttpServletResponse response){
List<OrderList> orderLi=orderService.queryAllOrders()
jo.put("total", orderLi.size());
jo.put("rows", orderLi);
try {
response.getWriter().append(JSON.toJSONString(jo, SerializerFeature.DisableCircularReferenceDetect));
} catch (IOException e) {
e.printStackTrace();
}
}

3. 引用是通过"$ref"来表示的
| 引用 | 描述 |
|---|---|
| "$ref":".." | 上一级 |
| "$ref":"@" | 当前对象,也就是自引用 |
| "$ref":"$" | 根对象 |
| "$ref":"$.children.0" | 基于路径的引用,相当于 root.getChildren().get(0)
|
979

被折叠的 条评论
为什么被折叠?



