我是来围观的逊 发表于 2021-1-11 10:31

Unity是否需要LitJson?

Unity是否需要LitJson?

dxf17 发表于 2021-1-11 10:39

1 首先是Unity内置的JsonUtility无法直接解析Json数组,只能解析最外层是Object的形式
比如

这样的直接解析不了,这是最难受的地方
2 解析类型丰富度。第三方可能可以解析DateTime,Dictionary等等更多的类型
3 性能问题。Unity内置的JsonUtility性能不行,网上有对比

刘冠华 发表于 2021-1-11 10:48

估计是因为其他插件使用它。通常我们都适用newtonjson

123456823 发表于 2021-1-11 10:53

因为unity本身那套json解析做的不够完善,很多人因为不熟悉,或者用着别扭,又或者不能满足需求,就会用自己偏爱的组件诸如litjson,newtonjson,besthttp的json库等

jimmy肖明 发表于 2021-1-11 10:54

"The JSON Serializer API supports any MonoBehaviour subclass, ScriptableObject subclass, or plain class or struct with the attribute. When you pass in an object to the standard Unity serializer for processing, the same rules and limitations apply as they do in the Inspector: Unity serializes fields only; and types like Dictionary<> are not supported.
Unity does not support passing other types directly to the API, such as primitive types or arrays. If you need to convert those, wrap them in a class or struct of some sort."
截取自官方文档。

井底燕雀傥 发表于 2021-1-11 11:02

请使用newtonjson
LitJson有些结构不是天然支持,比如字典,得自己加
页: [1]
查看完整版本: Unity是否需要LitJson?