A Jakarta REST provider for Jackson integration with RESTEasy. This provider supports Jackson 3.x and includes support for JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7396).
Full documentation is available at https://docs.resteasy.dev/resteasy-jackson-provider/.
The RESTEasy Jackson Provider offers Jackson integration for Jakarta REST applications targeting RESTEasy, including:
-
JSON serialization/deserialization using Jackson
-
JSON Patch (RFC 6902) support
-
JSON Merge Patch (RFC 7396) support
-
Jakarta JSON-P integration
-
JSR-310 date/time support
-
Polymorphic type handling with allowlist validation
-
RESTEasy tracing integration
Add the RESTEasy Jackson Provider to your project:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-bom</artifactId>
<version>${version.org.jboss.resteasy}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>tools.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${version.tools.jackson}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>dev.resteasy.providers</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>${version.dev.resteasy.providers.jackson}</version>
</dependency>
</dependencies>The provider is automatically registered via the JacksonFeature class when present on the classpath.
@Path("/api")
public class MyResource {
@GET
@Path("/data")
@Produces(MediaType.APPLICATION_JSON)
public MyData getData() {
return new MyData("example", 42);
}
@POST
@Path("/data")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public MyData createData(MyData data) {
// Process the data
return data;
}
}Enable pretty-printing by configuring the JsonMapper with SerializationFeature.INDENT_OUTPUT via a
ContextResolver<JsonMapper>:
@Provider
public class PrettyPrintMapperProvider implements ContextResolver<JsonMapper> {
@Override
public JsonMapper getContext(final Class<?> type) {
return JsonMapper.builder()
.enable(SerializationFeature.INDENT_OUTPUT)
.build();
}
}JSON Patch (RFC 6902) allows you to express a sequence of operations to apply to a JSON document:
@PATCH
@Path("/customer/{id}")
@Consumes("application/json-patch+json")
@Produces(MediaType.APPLICATION_JSON)
public Customer patchCustomer(@PathParam("id") String id, ObjectPatch patch) {
Customer customer = findCustomer(id);
return patch.apply(customer);
}Example JSON Patch request:
[
{ "op": "replace", "path": "/name", "value": "New Name" },
{ "op": "add", "path": "/tags/-", "value": "new-tag" },
{ "op": "remove", "path": "/temporary" }
]JSON Merge Patch (RFC 7396) provides a simpler patching mechanism:
@PATCH
@Path("/customer/{id}")
@Consumes("application/merge-patch+json")
@Produces(MediaType.APPLICATION_JSON)
public Customer mergePatchCustomer(@PathParam("id") String id, ObjectPatch patch) {
Customer customer = findCustomer(id);
return patch.apply(customer);
}Example JSON Merge Patch request:
{
"name": "Updated Name",
"email": "newemail@example.com"
}The provider can be configured by registering a ContextResolver<JsonMapper> to customize Jackson’s JsonMapper:
@Provider
public class CustomJsonMapperProvider implements ContextResolver<JsonMapper> {
@Override
public JsonMapper getContext(final Class<?> type) {
return JsonMapper.builder()
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();
}
}Releasing the project requires permission to deploy to Maven Central see Maven Central Release Requirements.
Once everything is setup, you simply need to run the ./release.sh script. There are two required parameters:
-
-ror--releasewhich is the version you want to release -
-dor--developmentwhich is the next development version.
By default, the release version cannot contain SNAPSHOT and the development version, must contain SNAPSHOT.
./release -r 1.0.0.Final -d 1.0.1.Final-SNAPSHOT| Argument | Requires Value | Description |
|---|---|---|
|
Yes |
The next version for the development cycle. |
|
No |
Forces to allow a SNAPSHOT suffix in release version and not require one for the development version. |
|
N/A |
Displays this help |
|
Unused |
Passes the |
|
Unused |
Passes the |
|
Yes |
The version to be released. Also used for the tag. |
|
No |
Executes the release in as a dry-run. Nothing will be updated or pushed. |
|
No |
Executes the release in, but doesn’t actually push the changes to GitHub or publish the release on Maven Central. Any next steps should you want to continue the release will need to be manual. |
|
No |
Prints verbose output. |
Any additional arguments are considered arguments for the Maven command.