Hacker News new | past | comments | ask | show | jobs | submit login
Fast, auto-generated streaming JSON parsing for Android (instagram-engineering.tumblr.com)
39 points by mikeyk on Sept 10, 2014 | hide | past | favorite | 15 comments



Cool - if this is indeed faster than Jackson (and GSON), I would recommend writing a Retrofit converter (https://github.com/square/retrofit/tree/master/retrofit-conv...) so developers can just drop in ig-json-parser for use with Retrofit.


This is based on Jackson stream parsing, so by definition, it can't be faster than Jackson. :)


This looks cool, but I'm also interested in seeing if compared to GSON not just Jackson. Is the `JsonField` annotation mandatory? In most cases my variable names are the same as the field names in the JSON, which is why I love using GSON since it auto-picks up on that.

It looks kind of odd in your sample code too, it'd be nice if it could auto-try those fields, but I can see why that won't work if this is compile-time rather than at processing-time like GSON (it has no way of checking against the JSON to see if that assumption is true) -- maybe have `JsonType` take and optional parameter that enables "guess types" mode?


Hi!

I'm one of the authors of this library. The code this library emits is very similar to the json/jackson/manual serializer/deserializer in https://github.com/eishay/jvm-serializers/wiki. Conveniently, GSON is benchmarked there too.

You're right, the field names could be guessed at compile time. Please feel free to submit a PR!

Thanks!


And look at how slow it still is. 40ms to parse json? I can do that around or under 1ms in iOS. When porting our app to android this was one of the biggest unexpected bottlenecks that really impacts performance. I don't know why android doesn't provide a native json implementation to reduce this barrier to entry.


Surely the size of the JSON payload matters for this benchmark. Just saying you can parse json in under 1 ms is somewhat meaningless unless you're comparing similar sized json documents, as well as marshalling into a user-supplied class.


And that's exactly what I'm comparing. This was the shock that came from the same data being loaded into android as ios being over an order of magnitude slower.


Interesting. What are you using for object marshalling on iOS? And which json processor are you using on your android benchmark? The referenced library?


Jackson (best performing) vs JSONKit. But Apple's is close enough as well.


I've added an issue to chidley to generate these classes, in addition to the Java/JAXB classes it produces now: https://github.com/gnewton/chidley/issues/4

(Of course only for json generation from XML)


How does this compare to loading up a String of json in an org.json.JSONObject and parsing it manually?

For some further abstraction/encapsulation, you can extend the JSONObject class and provide getters/settings for particular key/values.


The two are not really comparable since you get different results (JSONObjects are not strongly typed). You will easily be able to find workloads where one is better than the other, but in the average case, ig-json-parser will probably be faster because it's based on Jackson. (see json/jackson/manual vs json/org.json/manual on https://github.com/eishay/jvm-serializers/wiki)


How does this compare to GSON?



my first question after reading that post as well :P




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: