【发布时间】:2012-03-19 08:43:04
【问题描述】:
我正在使用 Gson 在我的应用程序中生成调试输出
Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create();
gson.toJson(myObject);
但 Gson 在尝试序列化数据结构时确实会抱怨循环引用错误。 这可以用 Jackson 库来完成吗?
UPD 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)
【问题讨论】: