org.json.JSONObject与Gson库JsonObject [英] org.json.JSONObject vs Gson library JsonObject
问题描述
这两个课程之间有什么区别?
What are differences between this two classes?
如果有人使用Gson库,则优先使用 com.google.json.JsonObject
而不是 org.json.JSONObject
?
If someone uses Gson library is it preferable to use com.google.json.JsonObject
over org.json.JSONObject
?
有人能列出这两种选择的利弊吗?
Could anybody list pros and cons of these 2 choices?
推荐答案
市场上有许多JSON实现,其中大多数是开源的.每个都有各自的优点和缺点.
Many JSON implementations are available in the market and most of them are open source. Each one has specific advantages and disadvantages.
- Google GSON
- 杰克逊
- org.json等
Google GSON 点击以获取官方信息文件
Google GSON click for official documents
- 提供简单的toJson()和fromJson()方法,将Java对象转换为JSON,反之亦然
- 允许预先存在的不可修改对象与JSON相互转换
- 对Java泛型的广泛支持
- 允许对象的自定义表示形式
- 支持任意复杂的对象(具有深层继承层次结构和泛型类型的广泛使用)
杰克逊 点击以获取正式文件
- 流式API或增量解析/生成:以离散事件的形式读取和写入JSON内容
- 树模型:提供JSON文档的可变的内存中树表示形式
- 数据绑定:将JSON与POJO的数据相互转换
一些比较博客请点击此处博客2
Some comparison blogs click here blogs1, blog2
我亲自使用GSON,Jackson,Simple JSON完成了序列化和反序列化的基准测试
I personally done a benchmark for serialization and deserialization using GSON vs Jackson vs Simple JSON
- 非常小的对象:Google gson的执行速度比Jackson和Simple JSON快
- 大对象:Google gson的执行速度比Jackson和Simple JSON快
这篇关于org.json.JSONObject与Gson库JsonObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!