This is a multi-module project that contains Jackson-based JAX-RS providers for following data formats:
Providers implement JAX-RS MessageBodyReader and MessageBodyWriter handlers for specific
data formats. They also contain SPI settings for auto-registration.
Module is fully functional and considered mature.
To use JAX-RS on Maven-based projects, use dependencies like:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.7.4</version>
</dependency>(above is for JSON provider; modify appropriately for other providers)
Due to auto-registration, it should be possible to simply add Maven dependency (or include jar if using other build systems) and let JAX-RS implementation discover provider. If this does not work you need to consult documentation of the JAX-RS implementation for details.
To use Jackson with Jersey see their documentation.
As of Jackson 2.8, there is a small supporting datatype module, jackson-datatype-jaxrs (see under datatypes/).
It will not be auto-registered automatically (unless user calls ObjectMapper.findAndRegisterModules()); instead,
user has to register it by normal means:
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jaxrs2TypesModule());
// and then register mapper with JAX-RS provider(s)and ensuring that configured mapper is used by JAX-RS providers.
It is possible that later versions of providers may offer additional ways to get datatype module registered.
In addition to annotation value classes, it is also possible to use a subset of Jackson annotations with provider.
Here is a short list of supported annotations that work with all formats:
@JsonViewcan be used to define active view for specific endpoint@JsonRootNamecan be used to specify alternate rootname; most often used with XML, but possibly with JSON as well.@JacksonAnnotationsInsidemeta-annotation may be used as a marker, to create "annotation bundles", similar to how they are used with value type annotationscom.fasterxml.jackson.jaxrs.annotation.JacksonFeaturescan be used with all provid to enable/disableSerializationFeature/DeserializationFeaturefor data-binding configurationJsonParser.Feature/JsonGenerator.Featurefor low(er) level Streaming read/write options
In addition there are format-specific annotations that may be used:
- JSON has:
com.fasterxml.jackson.jaxrs.json.annotation.JSONPto defineJSONPwrapping for serialized result
For documentation, downloads links, check out Wiki