users@jersey.java.net

[Jersey] Re: Jackson vs. MOXy

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 18 Dec 2013 18:28:39 +0100

We advertise MOXy as the recommended default, because it can support both JSON and XML as well as full set of JAXB annotations and more goodies (e.g. externalized bindings etc.). IOW, you can code your data model POJOs once and have them exposed as both JSON and XML for free. MOXy is also by default available in GlassFish and WebLogic, so you do not need to install any additional libraries in these app servers.

That said, you can use Jackson if you prefer it for some reason. Here's how:
https://jersey.java.net/documentation/2.4.1/media.html#json.jackson

As for other goodies, MOXy has a lot of extra features. From those directly related to Jersey, for example we currently support entity filtering with MOXy JSON providers. (To be fair, this is something we would like to support with Jackson too, sometime soon.)

Performance-wise, our internal tests indicate that Jackson is slightly faster at the moment. However, as soon as real network calls are involved, the performance difference is marginal. In general, you want to worry about design of your REST services wrt. latency caused by network and database communication; small server-side processing performance differences are irrelevant (as long as the server is scalable).

Marek

On 13 Dec 2013, at 22:41, Robert DiFalco <robert.difalco_at_gmail.com> wrote:

> I'm migrating from Jersey 1.9 to 2.x. Wow, what a lot of odds and ends to relearn. It looks like Moxy is preferred over Jackson (which I use in other parts of my code). I can make this change but before I do I have some questions:
>
> 1. Why is MOXy the "preferred" approach for Jersey 2.x?
> 2. Why was it selected over Jackson?
> 3. Have there been any speed comparisons between Moxy and Jackson for POJO mapping?
> 4. Should I just stick with Jackson for Jersey 2.x or will I get some special goodness from MOXy that I wont with Jackson?