JSON lib处理循环引用和抽象类?

时间:2022-10-29 19:43:47

I'm looking for a json (de)serialization library that can

我正在寻找一个json (de)序列化库。

  • serialize collections like List() and nested lists
  • 序列化列表()和嵌套列表等集合
  • can compete with circular references, as often occur in hibernate mappings
  • 可以与循环引用竞争,就像hibernate映射中经常发生的那样吗?
  • can handle lists with objects implementing a abstract class
  • 能处理实现抽象类的对象列表吗

I tried:

我试着:

  • Gson (has neither abstract class nor circular dep support. There are some hack extra classes, but they don't work well)

    Gson(既没有抽象类也没有循环dep支持。有一些黑客额外的类,但是它们不能很好地工作)

  • flexjson (has problems with deep lists)

    flexjson(有深度列表的问题)

Is there anything out that can handle all of this by not having to apply "hacky" things?

有什么东西可以通过不使用“陈腐”的东西来解决这一切吗?

3 个解决方案

#1


0  

Perhaps using YAML instead of JSON is an option? YAML is a superset of JSON and has built-in support for circular references and advanced data types.

也许使用YAML而不是JSON是一种选择?YAML是JSON的超集,支持循环引用和高级数据类型。

#2


0  

I finally found JACKSON to be very intuitive and easy configurable for all my needs. https://github.com/FasterXML/jackson-annotations

我终于发现杰克逊是非常直观和容易配置,以满足我的所有需要。https://github.com/FasterXML/jackson-annotations

#3


0  

Try http://x-stream.github.io/ (fast and feature rich) or http://json-lib.sourceforge.net (as @Cleber Alberto suggested) with customized circular references handling.

试试http://x-stream.github。io/(快速且特性丰富)或http://json-lib.sourceforge.net(如@Cleber Alberto所建议的)具有定制的循环引用处理。

#1


0  

Perhaps using YAML instead of JSON is an option? YAML is a superset of JSON and has built-in support for circular references and advanced data types.

也许使用YAML而不是JSON是一种选择?YAML是JSON的超集,支持循环引用和高级数据类型。

#2


0  

I finally found JACKSON to be very intuitive and easy configurable for all my needs. https://github.com/FasterXML/jackson-annotations

我终于发现杰克逊是非常直观和容易配置,以满足我的所有需要。https://github.com/FasterXML/jackson-annotations

#3


0  

Try http://x-stream.github.io/ (fast and feature rich) or http://json-lib.sourceforge.net (as @Cleber Alberto suggested) with customized circular references handling.

试试http://x-stream.github。io/(快速且特性丰富)或http://json-lib.sourceforge.net(如@Cleber Alberto所建议的)具有定制的循环引用处理。