Skip to content

Commit

Permalink
Merge pull request #4970 from loicmathieu/feat/jackson-java8-modules
Browse files Browse the repository at this point in the history
Add jackson jdk8 modules
  • Loading branch information
gsmet authored Oct 29, 2019
2 parents 1c8ed9b + 7322176 commit 696cc58
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
12 changes: 12 additions & 0 deletions extensions/jackson/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import javax.inject.Singleton;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;

import io.quarkus.arc.DefaultBean;

Expand All @@ -17,6 +20,7 @@ public class ObjectMapperProducer {
@Produces
public ObjectMapper objectMapper(Instance<ObjectMapperCustomizer> customizers) {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModules(new Jdk8Module(), new JavaTimeModule(), new ParameterNamesModule());
for (ObjectMapperCustomizer customizer : customizers) {
customizer.customize(objectMapper);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package io.quarkus.it.resteasy.jackson;

import java.time.LocalDate;

public class Greeting {

private final String message;
private final LocalDate date;

public Greeting(String message) {
public Greeting(String message, LocalDate date) {
this.message = message;
this.date = date;
}

public String getMessage() {
return message;
}

public LocalDate getDate() {
return date;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.it.resteasy.jackson;

import java.time.LocalDate;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
Expand All @@ -11,6 +13,6 @@ public class GreetingResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Greeting hello() {
return new Greeting("hello");
return new Greeting("hello", LocalDate.of(2019, 01, 01));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ void testEndpoint() {
.when().get("/greeting")
.then()
.statusCode(200)
.body(containsString("hello"));
.body(containsString("hello"))
.body(containsString("[2019,1,1]"));
}

}

0 comments on commit 696cc58

Please sign in to comment.