Search in sources :

Example 21 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project CzechIdMng by bcvsolutions.

the class WebConfig method objectMapper.

/**
 * Adds joda time json module
 */
@Bean
public ObjectMapper objectMapper() {
    ObjectMapper mapper = super.objectMapper();
    mapper.registerModule(new JodaModule());
    return mapper;
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) FilterRegistrationBean(org.springframework.boot.context.embedded.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 22 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project api-core by ca-cwds.

the class ObjectMapperUtils method configureObjectMapper.

/**
 * Configure given ObjectMapper.
 *
 * {@link ObjectMapper}, used to deserialize JSON Strings from source into instances of chosen
 * type.
 *
 * <p>
 * This mapper is thread-safe and reusable across multiple threads, yet any configuration made to
 * it, such as ignoring unknown JSON properties, applies to ALL target class types.
 * </p>
 *
 * <p>
 * Relax strict constraints regarding unknown JSON properties, since API classes may change over
 * time, and not all classes emit version information in JSON.
 * </p>
 *
 * <p>
 * Fixes bug #140710983: Bug: Person Search converts dates to GMT. Set default time zone to JVM
 * default, which must match the database and Elasticsearch server.
 * </p>
 *
 * @param objectMapper ObjectMapper to configure
 */
public static void configureObjectMapper(ObjectMapper objectMapper) {
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false);
    // The mainframe DB2 database runs in PST, and so we must too.
    final TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
    final DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    fmt.setTimeZone(tz);
    objectMapper.setDateFormat(fmt);
    objectMapper.getSerializationConfig().with(fmt);
    objectMapper.setTimeZone(tz);
    objectMapper.getSerializationConfig().with(tz);
    objectMapper.registerModule(new JodaModule());
}
Also used : TimeZone(java.util.TimeZone) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) SimpleDateFormat(java.text.SimpleDateFormat)

Example 23 with JodaModule

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

the class ExecModule method configure.

@Override
public void configure(Binder binder) {
    Preconditions.checkNotNull(binder, "binder is null.");
    binder.bind(BulkLoader.class);
    binder.bind(ILoggerFactory.class).toProvider(LoggerProvider.class).in(Scopes.SINGLETON);
    binder.bind(ModelManager.class).in(Scopes.SINGLETON);
    binder.bind(BufferAllocator.class).to(PooledBufferAllocator.class).in(Scopes.SINGLETON);
    binder.bind(TempFileAllocator.class).in(Scopes.SINGLETON);
    // GuessExecutor, PreviewExecutor
    registerPluginTo(binder, ParserPlugin.class, "system_guess", GuessExecutor.GuessParserPlugin.class);
    registerPluginTo(binder, ParserPlugin.class, "system_sampling", SamplingParserPlugin.class);
    // LocalExecutorPlugin
    registerPluginTo(binder, ExecutorPlugin.class, "local", LocalExecutorPlugin.class);
    // serde
    ObjectMapperModule mapper = new ObjectMapperModule();
    DateTimeZoneSerDe.configure(mapper);
    TimestampSerDe.configure(mapper);
    CharsetSerDe.configure(mapper);
    LocalFileSerDe.configure(mapper);
    // jackson-datatype-guava
    mapper.registerModule(new GuavaModule());
    // jackson-datatype-joda
    mapper.registerModule(new JodaModule());
    mapper.configure(binder);
}
Also used : ObjectMapperModule(com.fasterxml.jackson.module.guice.ObjectMapperModule) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ModelManager(org.embulk.config.ModelManager) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule)

Example 24 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project nakadi by zalando.

the class JsonConfig method jacksonObjectMapper.

@Bean
@Primary
public ObjectMapper jacksonObjectMapper() {
    final ObjectMapper objectMapper = new ObjectMapper().setPropertyNamingStrategy(CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
    objectMapper.registerModule(enumModule());
    objectMapper.registerModule(new Jdk8Module());
    objectMapper.registerModule(new ProblemModule());
    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(WRITE_DATES_AS_TIMESTAMPS, false);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    return objectMapper;
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ProblemModule(org.zalando.problem.ProblemModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 25 with JodaModule

use of com.fasterxml.jackson.datatype.joda.JodaModule in project kylo by Teradata.

the class TriggerFeed method init.

@Override
protected void init(ProcessorInitializationContext context) {
    super.init(context);
    MAPPER.registerModule(new JodaModule());
    MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
    MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    this.preconditionListener = createPreconditionListener();
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule)

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