Jackson & Jettison usage in Jersey
Asked Answered
U

2

11

Jersey framework uses both Jackson and Jettison libraries for JSON unmarshalling/marshalling. AFAIK, Jettison is for for mapping JSON to XML (with different mechanism support like mapped notation) and Jackson is for JSON generation/parsing (I'm using this without Jersey also).

Will Jersey using these two for two different functionalities or both for same JSON generation/parsing functionality?

I only want support JSON format. At my first thought, it seems I can remove either of the dependencies and I think I can remove Jettison as Jacksone seems more natural choice for JSON generation/parsing.

Unguarded answered 30/8, 2011 at 18:58 Comment(0)
I
7

Jersey will use one or the other, not both, for all JSON processing. Recommendation as far as I know is to use Jackson; Jettison support is older and was implemented before Jackson became available. Jettison is still supported for compatibility reasons but unless some code relies on exact structure it produces (which differs from straight-forward mapping) there's little benefit from using it.

Inventory answered 31/8, 2011 at 11:53 Comment(4)
Thanks. But I m seeing the Jettison as dependency (I m using Maven), even though I m using regular/straight-forward mapping?Unguarded
Yeah if something else needs it (either during runtime or maybe just for compilation, as is the case for Jersey I think), it needs to be included. But whether it gets used is configurable with Jersey, and there is no harm in including it.Inventory
I disagree with the term "There is no harm in including it". Knowing what is used for what is important. Maven is making developers lazy and projects bloated.Basilicata
I agree with the general sentiment, and personally I try to minimize dependencies. But once you do know purpose of a specific library there's limited benefit in trying to trim dependencies of packages you have little control over, which is the case wrt Jersey's inclusion of some of providers.Inventory
R
1

I agree, use Jackson or even GSON from google. Jettison has too much limitations and the performance is also lower.

Roquefort answered 22/2, 2013 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.