Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 409
Eno Avatar asked Mar 23 '10 19:03

Eno


People also ask

What is the fastest JSON parser?

The simdjson library uses commonly available SIMD instructions and microparallel algorithms to parse JSON 4x faster than RapidJSON and 25x faster than JSON for Modern C++.

Is JSON parse efficient?

Parsing JSON is much more efficient than parsing object literals in JavaScript. This is true across all major JavaScript execution engines by up to 2x for an 8MB file, as demonstrated by this parsing benchmark.

How slow is JSON parsing?

The interesting thing we can notice is that parsing JSON text is 3-5x faster than parsing equivalent XML, and twice faster than parsing equivalent spatial point. JSON_VALUE is x2 slower than PATINDEX and CHARINDEX, which is expected since these functions have much simpler parsing logic.

What is JSON iterator?

JavaScript Object Notation, or JSON, has gained a lot of popularity as a data interchange format in recent years. Jsoniter is a new JSON parsing library aimed at offering a more flexible and more performant JSON parsing than the other available parsers.


3 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.

like image 159
CommonsWare Avatar answered Oct 06 '22 02:10

CommonsWare


Since API 11, there is a stream json parser in Android

like image 28
rds Avatar answered Oct 06 '22 02:10

rds


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.

like image 43
alexanderblom Avatar answered Oct 06 '22 03:10

alexanderblom