国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

json-lib出現There is a cycle in the hierarchy解決辦法

2019-11-21 00:43:38
字體:
來源:轉載
供稿:網友
解決辦法

1.設置JSON-LIB讓其過濾掉引起循環的字段。

Java代碼
復制代碼 代碼如下:

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);
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);

2.設置JSON-LIB的setCycleDetectionStrategy屬性讓其自己處理循環,省事但是數據過于復雜的話會引起數據溢出或者效率低下。
Java代碼
[code]
JsonConfig config = new JsonConfig();
config.setIgnoreDefaultExcludes(false);
config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
config.registerJsonValueProcessor(Date.class,new DateJsonValueProcessor("yyyy-MM-dd")); //date processor register
String tempStr = "{/"TotalRecords/":"+ total.toString() +",/"Datas/":"+JSONSerializer.toJSON(list,config).toString()+"}";
out.print(tempStr);
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黄平县| 临湘市| 金昌市| 荔浦县| 宁津县| 化隆| 新蔡县| 北川| 西乌珠穆沁旗| 渭源县| 望奎县| 星座| 丰宁| 鄄城县| 中卫市| 昭通市| 永州市| 高平市| 军事| 永修县| 长阳| 民乐县| 阜南县| 历史| 敖汉旗| 双牌县| 湖口县| 新昌县| 长兴县| 萨迦县| 宜章县| 肇州县| 鲁山县| 昌宁县| 德兴市| 喀喇| 台北市| 同心县| 莱西市| 乐山市| 民和|