相关疑难解决方法(0)

用Jackson将对象转储到String

我正在使用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)

java jackson gson

28
推荐指数
2
解决办法
4万
查看次数

标签 统计

gson ×1

jackson ×1

java ×1