Search in sources :

Example 41 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project alf.io by alfio-event.

the class MvcConfiguration method objectMapper.

@Bean
public ObjectMapper objectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JavaTimeModule());
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    return mapper;
}
Also used : JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Bean(org.springframework.context.annotation.Bean)

Example 42 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project vft-capture by videofirst.

the class FileSystemCaptureDaoTest method setUp.

@Before
public void setUp() throws IOException {
    // clean out any videos generated
    VftTesting.initTestFolders();
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JavaTimeModule());
    objectMapper.disable(WRITE_DATES_AS_TIMESTAMPS);
    target = new FileSystemCaptureDao(objectMapper, VftTesting.VFT_VIDEO_FOLDER);
}
Also used : JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 43 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project nixmash-blog by mintster.

the class WebConfig method configureMessageConverters.

// endregion
// region Messages
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.registerModule(new JavaTimeModule());
    converter.setObjectMapper(objectMapper);
    converters.add(converter);
    super.configureMessageConverters(converters);
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 44 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project minijax by minijax.

the class Json method getObjectMapper.

public static ObjectMapper getObjectMapper() {
    if (instance == null) {
        instance = new ObjectMapper();
        instance.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        instance.setSerializationInclusion(Include.NON_NULL);
        instance.registerModule(new JaxbAnnotationModule());
        instance.registerModule(new JavaTimeModule());
        instance.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        instance.registerModule(new AfterburnerModule());
    }
    return instance;
}
Also used : JaxbAnnotationModule(com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule) AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 45 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project SONG by overture-stack.

the class JsonDocUtils method getJsonNodeFromClasspath.

@SneakyThrows
public static JsonNode getJsonNodeFromClasspath(String fileName) {
    ObjectMapper mapper = new ObjectMapper().registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(new JavaTimeModule());
    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
    JsonNode actualObj = mapper.readTree(is);
    return actualObj;
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) ParameterNamesModule(com.fasterxml.jackson.module.paramnames.ParameterNamesModule) InputStream(java.io.InputStream) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SneakyThrows(lombok.SneakyThrows)

Aggregations

JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)75 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)59 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)16 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)7 ParameterNamesModule (com.fasterxml.jackson.module.paramnames.ParameterNamesModule)7 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)6 Test (org.junit.Test)6 Bean (org.springframework.context.annotation.Bean)6 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)5 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)4 Before (org.junit.Before)4 Primary (org.springframework.context.annotation.Primary)4 StdDateFormat (com.fasterxml.jackson.databind.util.StdDateFormat)3 LocalDateSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer)3 LocalDateTimeSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer)3 LocalTimeSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer)3 IOException (java.io.IOException)3 MetricsModule (com.codahale.metrics.json.MetricsModule)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)2 Module (com.fasterxml.jackson.databind.Module)2