Friday, December 11, 2009

The argument about fast JSON processors

I have heard by now a number of times that Jettison is slower than Jackson when it comes to handling large JSON sequences.

To be honest, I am not sure what this argument is about. Perhaps because I do not understand JSON ? I would rather see statements like : Jackson is a popular JSON processor which can let users create correct JSON sequences without users having to introduce JAXB dependencies. This is something I can get.

The argument about the performance sounds like a red-herring to me. Are you writing a service which returns a 7OK JSON sequence ? Is it the sign you may need to rethink the way your service has been designed ? IMHO JSON is not the means to pass around huge sequences, it is the format which has been designed to help users streamline the development of client-facing Web frontends, at least this is my understanding.

So if you need to deal with large chunks of data then may be you may want to return a JSON-formatted Atom feed, something that Abdera supports, with links pointing back to the next chunks of data. Or just use XML for a similar purpose ?

And if you write your Ajax JavaScript clients handling JSON sequences of small to medium size then perhaps the performance issue is not actually an issue ?

Having said all this, I will be happy to see Jettison supporting streaming eventually. Hope it will happen soon. The most important thing though is that it will now more likely to produce correct JSON sequences which is what users really want.


Dan Diephouse said...

Jackson is way better than my piece of crap Jettison. I hacked it out in one night or so for a potential customer :).

I doubt Jettison will ever support streaming. It's really not possible with a model where you go from XMLStreamReader->JSON. You simply never know what elements are going to come so you can't anticipate if you need to write an array or a single value.

Sergey Beryozkin said...

Dan, good to hear from you :)

You are very modest :-) You might've not written your best piece of software during that night but you did do something that would come out sooner or later anyway, which is what the software pioneers do :-)

Lets see what happens around streaming. Perhaps it will be one way only, or perhaps it will be possible to configure Jettison to do streaming both ways in cases when it is known no ambiguities will arise

Anonymous said...

Your blog is very informative and very helpful. Thanks for this.
Web development