Search in sources :

Example 46 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)

Example 47 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project jhipster-sample-app-cassandra by jhipster.

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 48 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project vespa by vespa-engine.

the class Utils method createObjectMapper.

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

Example 49 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project jhipster-sample-app-elasticsearch by jhipster.

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 50 with JavaTimeModule

use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project jhipster-registry by jhipster.

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)81 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)65 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)17 Test (org.junit.Test)9 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)7 ParameterNamesModule (com.fasterxml.jackson.module.paramnames.ParameterNamesModule)7 Bean (org.springframework.context.annotation.Bean)7 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)6 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)5 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 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)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 PropertyNamingStrategy (com.fasterxml.jackson.databind.PropertyNamingStrategy)2 JsonMapper (com.fasterxml.jackson.databind.json.JsonMapper)2