Replace standard Android JSON parser for better performance?
Solution 1
Well, here are a couple of links comparing Jackson JSON performance with existing JSON, SAX, and Protocol Buffers. According to the author, Jackson is faster than SAX or the built-in JSON and about on par with Protocol Buffers. That last part sounds a little suspicious, but, regardless, it certainly appears Jackson works on Android and may be worth some experimentation.
I haven't checked the JAR size, though. If it's huge, unless you were dying for extra JSON performance, it might not be worth the space hit.
Solution 2
Since API 11, there is a stream json parser in Android
Solution 3
Late answer but it might still help. I'm using Jackson for parsing JSON from Twitter as well as persisting Maps
to the database. The data mapping in Jackson is just wonderful. Being able to map JSON directly to an object is awesome and makes everything alot cleaner.
Even if you are only parsing simple replies data mapping might help you make your code cleaner (and more efficient). For me it's godsend that I don't have to write parsing logic for every type of Twitter api function.
Related videos on Youtube
Eno
Experienced mobile / web developer and systems admin (Linux, Solaris). Ive been using Linux since 1992 (anyone remember the SLS distro? But I still love my ole Beeb ;-)
Updated on April 17, 2022Comments
-
Eno about 2 years
I know that Android has a JSON parser baked in but I was wondering if it was worth using something that offered better performance (like Jackson - see http://jackson.codehaus.org/) ? Anybody tried that ?
-
Eno about 14 yearsYes, file size is definately in my list of possible constraints. I guess if I was chewing through lots of JSON in my app, it might be worth adding Jackson, but Ill stick with the standard JSON for now.
-
Eno about 14 yearsThanks for that feedback - great to have another tool in the chest if needed.
-
christophercotton over 11 yearsThanks! I didn't notice that was there since it wasn't in the JSON package
-
rds almost 4 yearsEdit: protocol buffers is what you want for best performances