将对象转储到具有 Jackson 的字符串
我正在使用Gson在我的应用程序中生成调试输出
Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create();
gson.toJson(myObject);
但是Gson确实抱怨在尝试序列化数据结构时出现循环引用错误。这可以用杰克逊图书馆完成吗?
断续器Gson 2.3.1:2014年11月20日发布
Added support to serialize objects with self-referential fields. The self-referential field is set to null in JSON. Previous version of Gson threw a StackOverflowException on encountering any self-referential fields.
The most visible impact of this is that Gson can now serialize Throwable (Exception and Error)