Android gson streaming parser or android.util.jsonreader?
android, gson, json, streaming
Solution
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.
Problem
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.