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

Java代碼 復制代碼 代碼如下: JsonConfig config = new JsonConfig(); config.setIgnoreDefaultExcludes(false); config.setCycleDetectionStrategy(CycleDe " /> 性生交大片免费一级,国产日韩在线观看视频,美女视频永久黄网站免费观看国产

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

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

解決辦法

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

JavaScript技術json-lib出現There is a cycle in the hierarchy解決辦法,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 天天干天天射天天爽 | 99久在线精品99re6视频 | 国产不卡福利 | 在线视频一区二区三区 | 精品国产成人a区在线观看 精品国产成人a在线观看 | 久久久久久久久性潮 | 99精品国产闺蜜国产在线闺蜜 | 国产精品伦理久久久久久 | 欧美a级黄色片 | 日韩av成人| 国产在线精品美女观看 | 乱码一区| 国产激情在线 | 国产播放器一区 | 自拍 欧美 日韩 | 亚洲国产中文字幕在线观看 | 五月激情六月 | 伊人久久综合网亚洲 | 婷婷视频网站 | 日本乱人伦在线观看免费 | 日日摸夜夜添夜夜添毛片 | 免费人成综合在线视频 | 国产美女网站 | 精品国产免费一区二区 | 色香蕉网站 | 四虎入口| 精品国产一区二区三区麻豆小说 | 国产美女久久久 | 欧美日本韩国一区二区 | www成人国产在线观看网站 | 亚洲第一香蕉视频 | 成年ssswww日本 | 国产日韩精品一区在线不卡 | 成人午夜免费视频毛片 | 久久91精品综合国产首页 | 欧美成人久久久 | 亚洲黄色一级毛片 | 99久久精品99999久久 | 日韩午夜免费 | 成人午夜视频一区二区国语 | 全部免费69堂在线视频 |