Search in sources :

Example 1 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project opsgenie-configuration-backup by opsgenie.

the class PolicyImporter method readJson.

private PolicyWithTeamInfo readJson(String policyJson) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    mapper.setDateFormat(sdf);
    return mapper.readValue(policyJson, PolicyWithTeamInfo.class);
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) SimpleDateFormat(java.text.SimpleDateFormat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project druidry by zapr-oss.

the class TimeSeriesTest method init.

@BeforeClass
public void init() {
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project syncope by apache.

the class SyncopeClientFactoryBean method defaultJsonProvider.

protected JacksonJaxbJsonProvider defaultJsonProvider() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    return new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project tutorials by eugenp.

the class JacksonDateUnitTest method whenSerializingJodaTime_thenCorrect.

@Test
public void whenSerializingJodaTime_thenCorrect() throws JsonProcessingException {
    final DateTime date = new DateTime(2014, 12, 20, 2, 30, DateTimeZone.forID("Europe/London"));
    final ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    final String result = mapper.writeValueAsString(date);
    assertThat(result, containsString("2014-12-20T02:30:00.000Z"));
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) Matchers.containsString(org.hamcrest.Matchers.containsString) LocalDateTime(java.time.LocalDateTime) DateTime(org.joda.time.DateTime) EventWithLocalDateTime(com.baeldung.jackson.date.EventWithLocalDateTime) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 5 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project modesti by jlsalmon.

the class RestConfig method configureJacksonObjectMapper.

@Override
public void configureJacksonObjectMapper(ObjectMapper objectMapper) {
    SimpleModule module = new SimpleModule("CustomModule");
    module.addAbstractTypeMapping(Point.class, PointImpl.class);
    objectMapper.registerModule(module);
    // Register a deserialiser for Joda classes
    objectMapper.registerModule(new JodaModule());
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Aggregations

JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)45 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)37 Test (org.junit.Test)15 IOException (java.io.IOException)14 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Resource (org.springframework.core.io.Resource)6 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)5 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)5 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)5 SimpleDateFormat (java.text.SimpleDateFormat)4 Bean (org.springframework.context.annotation.Bean)4 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)3 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 Primary (org.springframework.context.annotation.Primary)3 MetricsModule (com.codahale.metrics.json.MetricsModule)2 PropertyNamingStrategy (com.fasterxml.jackson.databind.PropertyNamingStrategy)2 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)2 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)2