Android的gson流解析器或android.util.jsonreader? [英] Android gson streaming parser or android.util.jsonreader?
问题描述
我正在寻找在Android应用中使用流式json解析器,我想知道是使用gson还是android.util.jsonreader库。假设许可和版本兼容性不是问题,我应该更喜欢这样做:
- 我处理几MB数据。
- JSON主要由压缩字符串组成,所以我并不真的需要一个Object到JSON映射。
它并不重要: android.util.JsonReader 和 com.google.gson.stream.JsonReader 是相同的代码。这两个类具有相同的API和相同的行为。
也就是说,有一些微小的差异:
I'm looking to use a a streaming json parser in an Android app, and I am wondering whether to use gson or the android.util.jsonreader library. Supposing that licensing and version compatibility are not a problem, which should I prefer given that:
- I process several MBs of data.
- JSON mostly consists of compressed strings, so I don't really need an Object to JSON mapping.
It doesn't much matter: android.util.JsonReader and com.google.gson.stream.JsonReader are the same code. The two classes have the same API and the same behavior.
That said, there are some tiny differences:
- Android's JsonReader is only available in Android 3.0 and later. The Gson one is available in a standalone jar file that you can use on any version of Android.
- Gson's may be a tiny bit faster simply because it always has the latest optimizations. The version on shipping Android devices is always slightly older than the latest and greatest. For most applications you won't notice this difference.
这篇关于Android的gson流解析器或android.util.jsonreader?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!