Search in sources :

Example 6 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project camunda-bpm-platform by camunda.

the class JodaJsonDataFormatConfigurator method configure.

@Override
public void configure(JacksonJsonDataFormat dataFormat) {
    ObjectMapper objectMapper = dataFormat.getObjectMapper();
    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)

Example 7 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project ninja by ninjaframework.

the class ObjectMapperProvider method get.

@Override
public ObjectMapper get() {
    ObjectMapper objectMapper = new ObjectMapper();
    // Afterburner optimizes performance of Pojo to Json mapper
    objectMapper.registerModule(new AfterburnerModule());
    // Java 8 data type
    objectMapper.registerModule(new JavaTimeModule());
    objectMapper.registerModule(new Jdk8Module());
    // Joda
    objectMapper.registerModule(new JodaModule());
    return objectMapper;
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 8 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class CurationApplication method getObjectMapper.

@Bean(name = "JodaMapper")
@Primary
public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule()).configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false).configure(SerializationFeature.INDENT_OUTPUT, true).setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper;
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 9 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionSubmissionTest method testReadSubmissionEnvelopes.

@Test
public void testReadSubmissionEnvelopes() {
    try {
        Resource resource = new ClassPathResource("envelope-submissions.json");
        assertTrue(resource.exists());
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.registerModule(new JodaModule());
        DepositionSubmission[] submission = objectMapper.readValue(resource.getFile(), DepositionSubmission[].class);
        assertNotNull(submission);
        assertEquals("2020-04-27T13:17:27.724Z", submission[0].getCreated().getTimestamp().toString());
        assertNotNull(submission[0].getStatus());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) ClassPathResource(org.springframework.core.io.ClassPathResource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 10 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project goci by EBISPOT.

the class DepositionPublicationTest method testReadAllPublications.

@Test
public void testReadAllPublications() {
    try {
        Resource resource = new ClassPathResource("publications.json");
        assertTrue(resource.exists());
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.registerModule(new JodaModule());
        DepositionPublicationListWrapper publication = objectMapper.readValue(resource.getFile(), DepositionPublicationListWrapper.class);
        assertNotNull(publication);
        assertNotNull(publication.getPublications().getPublications().get(0).getPublicationDate().year());
        assertNotNull(publication.getPublications().getPublications().get(0).getStatus());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) ClassPathResource(org.springframework.core.io.ClassPathResource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DepositionPublicationListWrapper(uk.ac.ebi.spot.goci.model.deposition.util.DepositionPublicationListWrapper) Test(org.junit.Test)

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