Search code examples
jerseyjacksonjax-rsportabilityjettison

Jersey Use Jackson or Jettison for JSONConfiguration.natural().build()


I am trying to portable rest application for Weblogic and Jboss. Currently we are using jersey for rest app. with portable implementation jboss will use resteasy.

Context: in our app we are @Provider class using ContextResolver<JAXBContext> return JSONJAXBContext with JSONConfiguration.natural().build(). so i am trying to find jersey internally used above configuration for Jackson or Jettison. please help me on this.


Solution

  • Consider forgetting anything to do with Jersey, if you're looking for portability. You can simply use the jackson-jaxrs-json-provider. If you are allowing for resource/providers to be auto-discovered, then there should be no extra configuration for this provider needed.

    If you are registering resources/providers explicitly, then you should register either JacksonJsonProvider or JacksonJsonJaxbProvider (if you need JAXB annotation support). If you are using auto-registration (scanning), then as stated earlier, these providers will be be implicitly registered for you.

    As for the ContentResolver, if you need to configure the marshaller/unmarshaller, the you should use the Jackson's ObjectMapper (e.g. implements ContextResolver<ObjectMapper>). There are many different configurations for the ObjectMapper