找回密码
 立即注册
查看: 573|回复: 5

Unity是否需要LitJson?

[复制链接]
发表于 2021-1-11 10:31 | 显示全部楼层 |阅读模式
Unity是否需要LitJson?
发表于 2021-1-11 10:39 | 显示全部楼层
1 首先是Unity内置的JsonUtility无法直接解析Json数组,只能解析最外层是Object的形式
比如
[1,2,3]
这样的直接解析不了,这是最难受的地方
2 解析类型丰富度。第三方可能可以解析DateTime,Dictionary等等更多的类型
3 性能问题。Unity内置的JsonUtility性能不行,网上有对比
发表于 2021-1-11 10:48 | 显示全部楼层
估计是因为其他插件使用它。通常我们都适用newtonjson
发表于 2021-1-11 10:53 | 显示全部楼层
因为unity本身那套json解析做的不够完善,很多人因为不熟悉,或者用着别扭,又或者不能满足需求,就会用自己偏爱的组件诸如litjson,newtonjson,besthttp的json库等
发表于 2021-1-11 10:54 | 显示全部楼层
"The JSON Serializer API supports any MonoBehaviour subclass, ScriptableObject subclass, or plain class or struct with the [Serializable] 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有些结构不是天然支持,比如字典,得自己加
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-9-20 11:50 , Processed in 0.067335 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表