English 中文(简体)
Replace standard Android JSON parser for better performance?
原标题:

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 ?

最佳回答

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.





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

Locating specific string and capturing data following it

I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...

热门标签