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/) ?开发者_StackOverflow中文版 Anybody tried that ?
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.
Since API 11, there is a stream json parser in Android
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.
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.
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.
精彩评论