Search in sources :

Example 1 with JavaTimeModule

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

the class DefaultConfigDataBuilder method newDefaultObjectMapper.

public static ObjectMapper newDefaultObjectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    objectMapper.registerModule(new Jdk8Module());
    objectMapper.registerModule(new GuavaModule());
    objectMapper.registerModule(new JavaTimeModule());
    JsonFactory factory = objectMapper.getFactory();
    factory.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
    factory.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
    return objectMapper;
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) JsonFactory(com.fasterxml.jackson.core.JsonFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule)

Example 2 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project data-transfer-project by google.

the class ObjectMapperFactory method createObjectMapper.

public static ObjectMapper createObjectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JavaTimeModule());
    return objectMapper;
}
Also used : JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with JavaTimeModule

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

the class TestUtil method convertObjectToJsonBytes.

/**
 * Convert an object to JSON byte array.
 *
 * @param object
 *            the object to convert
 * @return the JSON byte array
 * @throws IOException
 */
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    JavaTimeModule module = new JavaTimeModule();
    mapper.registerModule(module);
    return mapper.writeValueAsBytes(object);
}
Also used : JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with JavaTimeModule

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

the class TestUtil method convertObjectToJsonBytes.

/**
 * Convert an object to JSON byte array.
 *
 * @param object
 *            the object to convert
 * @return the JSON byte array
 * @throws IOException
 */
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    JavaTimeModule module = new JavaTimeModule();
    mapper.registerModule(module);
    return mapper.writeValueAsBytes(object);
}
Also used : JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with JavaTimeModule

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

the class TestUtil method convertObjectToJsonBytes.

/**
 * Convert an object to JSON byte array.
 *
 * @param object
 *            the object to convert
 * @return the JSON byte array
 * @throws IOException
 */
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    JavaTimeModule module = new JavaTimeModule();
    mapper.registerModule(module);
    return mapper.writeValueAsBytes(object);
}
Also used : JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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