There is a cycle in the hierarchy!

问题描述:

There is a cycle in the hierarchy!
List res = resourceService.findAll();
JSONArray datalist = JSONArray.fromObject(res);//这里报错there is a cycle in the hierarchy
用网上提供的方法不好使
下面是Resource属性
private Integer id;
\x05private String title;
\x05private String description;
\x05private Set roles = new HashSet();
Resource和Role有多对多的关系
Role的属性
private Integer id;
\x05private String roleName;
\x05private Set res = new HashSet();
1个回答 分类:综合 2014-10-17

问题解答:

我来补答
有把有关联的属性放到json数组中就可以了.因为Resource的json数组中有roles数组,而且roles的数组元素中又有Resource数组,死循环了.用JSONConfig把roles去除就可以了.
 
 
展开全文阅读
剩余:2000