我正在使用Gson在我的应用程序中生成调试输出
Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create();
gson.toJson(myObject);
Run Code Online (Sandbox Code Playgroud)
但在尝试序列化数据结构时,Gson确实抱怨循环引用错误.这可以用杰克逊图书馆完成吗?
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)
Run Code Online (Sandbox Code Playgroud)