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 ?
-
I've never had issues with the speed of Android's JSON parser. I've even got a 41kb JSON file in one of my apps, and it loads in a couple hundred ms on a G1 (which is just fine, as it only needs to run once when the app boots). – Dan Lew Mar 23 '10 at 19:32
-
Absolute speaking speed may well be acceptable. It's still good to consider that on regular desktop CPUs, JSON parsing speed is in order of tens of megs -- 41 kb file would be done in millisecond or so. Even given slower CPUs Android system often have, a hundred milliseconds is rather slow, relative to fast alternatives. So, right tool for the job. For casual use (like reading in config file on startup) in-built handlers are usually decent. It's still good to know that there is room for improvement if use cases demands it. – StaxMan Mar 30 '10 at 05:44
5 Answers
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.

- 986,068
- 189
- 2,389
- 2,491
-
Yes, 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 Mar 23 '10 at 21:30
Since API 11, there is a stream json parser in Android

- 26,253
- 19
- 107
- 134
-
Thanks! I didn't notice that was there since it wasn't in the JSON package – christophercotton Dec 24 '12 at 17:55
-
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.

- 8,632
- 6
- 34
- 40
-
Thanks for that feedback - great to have another tool in the chest if needed. – Eno Mar 29 '10 at 18:10
I use jackson json to implement my android application which communicates with server via json-rpc. I wold like to use it to serialize/deserialize json-rpc requests and responses and objects to transfer the data. I use 2.0 version of Jackson-json. I have put in my build path two jars: jackson-databind-2.0.0.jar, jackson-core-2.0.0.jar and jackson-annotations-2.0.0.jar.
On the side note: Are there any json-rpc implementation for the android. separate json-rpc and http traffic would be good. I have googled a lot, bu have not found good json-rpc generator, json serializer / deserializer and for the transport I will go with android-query.

- 1,011
- 2
- 11
- 24
Just one more perspective on these parsers. I was looking through the Google IO for 2009 and there is really nice talk about efficient use of battery for app developers.
Here is the link to that talk : link
Now as per the talk inbuilt parson for android is Tree Based and these are supposed to be inefficient when it comes to battery life. Has anyone really looked into this.
Reading through this discussion it seem Jackson parser seems to be a winner in everything. Its almost equally fast if not more than inbuilt one and also its Event/Stream based as opposed to tree based which is better in terms of battery usage.
Just a though I wanted to share and get some opinions on this.