分享

net.sf.json.JSONException: There is a cycle in the hierarchy

 shen1565 2013-11-12
java 对象解析为字符串时出现死循环 解决方案:

String cardId=ActionUtil.getParameter("cardId");
List<MonthBudget> monthBudgets=fublishFeeService.queryFeePlan(cardId);
if(monthBudgets!=null && !"".equals(monthBudgets)){
JsonConfig jcf=new JsonConfig();
jcf.setJsonPropertyFilter(new PropertyFilter() {
@Override
public boolean apply(Object arg0, String arg1, Object arg2) {
// TODO 返回true就可过滤掉
if(arg1.equals("rollBudget")){
return true;
}
if(arg1.equals("monthBudget")){
return true;
}
return false;
}
});
JSONArray jsonArray = JSONArray.fromObject(monthBudgets,jcf);
ActionUtil.write(jsonArray.toString());
return;
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约