JSON: Jackson stream parser - is it really worth it?
- by synic
I'm making pretty heavy use of JSON parsing in an app I'm writing. Most of what I have done is already implemented using Android's built in JSONObject library (is it json-lib?).
JSONObject appears to create instances of absolutely everything in the JSON string... even if I don't end up using all of them.
My app currently runs pretty well, even on a G1.
My question is this: are the speed and memory benefits from using a stream parser like Jackson worth all the trouble?
By trouble, I mean this: As far as I can tell, there are three downsides to using Jackson instead of the built in library:
Dependency on an external library. This makes your .apk bigger in the end. Not a huge deal.
Your app is more fragile. Since the parsing is not done automatically, it is more vulnerable to changes in the JSON text that it's parsing. I'm extremely worried that malformed JSON will result in infinite loops (as pull parsing requires a lot of while loops).
Writing code to parse JSON via a stream parser is ugly and tedious.