Skip to content

Commit

Permalink
Automatically serialize/deserialize Java 8 datatype
Browse files Browse the repository at this point in the history
This patch adds support for automatically serializing and deserialzing for new "datatypes" introduced in Java 8 for jersey-media-json-jackson module.

Signed-off-by: praveenkrishna <praveenkrishna@tutanota.com>
  • Loading branch information
Praveen2112 authored and praveenkrishna committed Nov 5, 2019
1 parent 72c27bc commit 72d8113
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions media/json-jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.Annotations;
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.MapperConfiguratorBase;

Expand Down Expand Up @@ -44,6 +45,8 @@ public synchronized ObjectMapper getConfiguredMapper() {
public synchronized ObjectMapper getDefaultMapper() {
if (_defaultMapper == null) {
_defaultMapper = new ObjectMapper();
// We can remove this once we move to Jackson 3.0
_defaultMapper.registerModule(new Jdk8Module());
_setAnnotations(_defaultMapper, _defaultAnnotationsToUse);
}
return _defaultMapper;
Expand All @@ -65,6 +68,8 @@ protected ObjectMapper mapper()
{
if (_mapper == null) {
_mapper = new ObjectMapper();
// We can remove this once we move to Jackson 3.0
_mapper.registerModule(new Jdk8Module());
_setAnnotations(_mapper, _defaultAnnotationsToUse);
}
return _mapper;
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,12 @@
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions tests/osgi/functional/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@
<artifactId>jackson-xc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.sun.xml.bind</groupId>
Expand Down

0 comments on commit 72d8113

Please sign in to comment.