jackson 是否处理/抛出循环异常,例如当检测到要转换为 json 的 java 对象中的循环时,在 json-lib 中抛出 net.sf.json.JSONException: There is a Cycle in the Hierarchy! 。如果是的话我们该如何处理。
json-lib中抛出的错误如下
1169 SEVERE: Servlet.service() for servlet JSONControllerServletGZIP threw exception
1170 net.sf.json.JSONException: There is a cycle in the hierarchy!
1171 at net.sf.json.util.CycleDetectionStrategy$StrictCycleDetectionStrategy.handleRepeatedReferenceAsArray(CycleDetectionStra
1172 at net.sf.json.JSONArray._fromCollection(JSONArray.java:749)
1173 at net.sf.json.JSONArray.fromObject(JSONArray.java:165)
1174 at net.sf.json.JSONObject._processValue(JSONObject.java:2132)
1175 at net.sf.json.JSONObject._setInternal(JSONObject.java:2177)
1176 at net.sf.json.JSONObject.setValue(JSONObject.java:1005)
1177 at net.sf.json.JSONObject._fromMap(JSONObject.java:886)
1178 at net.sf.json.JSONObject.fromObject(JSONObject.java:248)
提前致谢。
最佳答案
关于java - Jackson 会抛出循环异常吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9111922/