您当前的位置: 首页 >  ar

There is a cycle in the hierarchy

发布时间:2014-04-29 10:02:36 ,浏览量:0

在使用JSONObject.fromObject的时候,出现“There is a cycle in the hierarchy”异常。

意思是出现了死循环,也就是Model之间有循环包含关系;

解决办法:

使用setCycleDetectionStrategy防止自包含

代码:

JsonConfig jsonConfig = new JsonConfig();

jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);

JSONObject json =JSONObject.fromObject(model, jsonConfig);

result = json.toString();

依赖的包: 

import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.util.CycleDetectionStrategy;

参考网页:

http://www.cnblogs.com/az19870227/archive/2011/09/19/2180993.html

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    108697博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0453s