json-lib出现There is a cycle in the hierarchy解决办法
来源:互联网 发布:苹果电脑做淘宝方便吗? 编辑:程序博客网 时间:2024/05/01 07:13
问题的出现
如果需要解析的数据间存在级联关系,而互相嵌套引用,在hibernate中极容易嵌套而抛出net.sf.json.JSONException: There is a cycle in the hierarchy异常。
1.设置JSON-LIB让其过滤掉引起循环的字段。
JsonConfig config = new JsonConfig(); config.setIgnoreDefaultExcludes(false); config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); config.registerJsonValueProcessor(Date.class,new DateJsonValueProcessor("yyyy-MM-dd")); //date processor register config.setExcludes(new String[]{//只要设置这个数组,指定过滤哪些字段。 "consignee", "contract", "coalInfo", "coalType", "startStation", "balanceMan", "endStation" }); String tempStr = "{/"TotalRecords/":"+ total.toString() +",/"Datas/":"+JSONSerializer.toJSON(list,config).toString()+"}"; out.print(tempStr);
- json-lib出现There is a cycle in the hierarchy解决办法
- json-lib出现There is a cycle in the hierarchy解决办法
- json-lib出现There is a cycle in the hierarchy解决办法
- json-lib 出现net.sf.json.JSONException: There is a cycle in the hierarchy异常的解决办法
- json-lib 出现net.sf.json.JSONException: There is a cycle in the hierarchy异常的解决办法
- json-lib There is a cycle in the hierarchy!
- 关于json-lib There is a cycle in the hierarchy!问题的3种解决办法
- 黑马bos项目运行json时出现There is a cycle in the hierarchy!的解决办法
- 使用Json-lib转换json字符串出现There is a cycle in the hierarchy!时的解决方案
- 使用JSON-lib时报There is a cycle in the hierarchy!错误的解决方案
- Json解析时出现net.sf.json.JSONException: There is a cycle in the hierarchy!42
- JSON There is a cycle in the hierarchy异常
- There is a cycle in the hierarchy解决办法
- There is a cycle in the hierarchy解决办法
- 出现“There is a cycle in the hierarchy”异常
- Json转换成字符串,There is a cycle in the hierarchy解决办法
- 使用JSONObject转换json数据报错:There is a cycle in the hierarchy!的解决办法
- There is a cycle in the hierarchy
- Target runtime Apache Tomcat v5.5 is not defined 错误维护
- 内核中的TCP的追踪分析-4-TCP(IPV4)的socket的地址绑定-续
- jrtplib介绍
- 全国省市数据库
- 排序总结+全排列
- json-lib出现There is a cycle in the hierarchy解决办法
- select_sort
- linux udp bind函数说明
- 黑发奶奶"曾世鑫"的养生经
- 个人android遇到的问题总结
- ^ō^码农------->自由创业^ō
- J-Flash ARM烧写Nor Flash时出错:PC of target system has unexpected value after programming
- could not find the adb
- 炮兵阵地详解