当前位置: 首页>>代码示例>>Java>>正文


Java JavaTimeModule.addDeserializer方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.datatype.jsr310.JavaTimeModule.addDeserializer方法的典型用法代码示例。如果您正苦于以下问题:Java JavaTimeModule.addDeserializer方法的具体用法?Java JavaTimeModule.addDeserializer怎么用?Java JavaTimeModule.addDeserializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.datatype.jsr310.JavaTimeModule的用法示例。


在下文中一共展示了JavaTimeModule.addDeserializer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertObjectToJsonBytes

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
/**
 * 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();
    module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
    module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
    mapper.registerModule(module);

    return mapper.writeValueAsBytes(object);
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:24,代码来源:TestUtil.java

示例2: convertObjectToJsonBytes

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
/**
 * 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();
    module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
    module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
    module.addSerializer(JSONObject.class, JSONObjectSerializer.instance);
    mapper.registerModule(module);

    return mapper.writeValueAsBytes(object);
}
 
开发者ID:OwnYourData,项目名称:oyd-pia,代码行数:25,代码来源:TestUtil.java

示例3: jackson2ObjectMapperBuilder

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
@Bean
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
    JavaTimeModule module = new JavaTimeModule();
    module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
    module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
    return new Jackson2ObjectMapperBuilder()
            .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            .findModulesViaServiceLoader(true)
            .modulesToInstall(module);
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:14,代码来源:JacksonConfiguration.java

示例4: jackson2ObjectMapperBuilder

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
@Bean
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
    JavaTimeModule module = new JavaTimeModule();
    module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
    module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
    return new Jackson2ObjectMapperBuilder()
        .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
        .findModulesViaServiceLoader(true)
        .modulesToInstall(module);
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:14,代码来源:JacksonConfiguration.java

示例5: jackson2ObjectMapperBuilder

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
@Bean
public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
    JavaTimeModule module = new JavaTimeModule();
    module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
    module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
    return new Jackson2ObjectMapperBuilder()
        .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
        .findModulesViaServiceLoader(true)
        .modulesToInstall(module);
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:14,代码来源:JacksonConfiguration.java

示例6: jackson2ObjectMapperBuilder

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
@Bean
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
    JavaTimeModule module = new JavaTimeModule();
    module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
    module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
    module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
    return new Jackson2ObjectMapperBuilder()
        .findModulesViaServiceLoader(true)
        .modulesToInstall(module);
}
 
开发者ID:k8s-for-greeks,项目名称:gpmr,代码行数:13,代码来源:JacksonConfiguration.java

示例7: convertObjectToJsonBytes

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
/**
 * 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();
    module.addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer(ISO_FIXED_FORMAT));
    module.addDeserializer(LocalDate.class, new LocalDateDeserializer(ISO_DATE_OPTIONAL_TIME));
    mapper.registerModule(module);

    return mapper.writeValueAsBytes(object);
}
 
开发者ID:dlwhitehurst,项目名称:blackhole,代码行数:21,代码来源:TestUtil.java

示例8: jackson2ObjectMapperBuilder

import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; //导入方法依赖的package包/类
@Bean
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
    JavaTimeModule module = new JavaTimeModule();

    module.addDeserializer(LocalDate.class, new CustomLocalDateDeserializer());
    module.addSerializer(LocalDate.class, new CustomLocalDateSerializer());

    module.addDeserializer(LocalDateTime.class, new CustomLocalDateTimeDeserializer());
    module.addSerializer(LocalDateTime.class, new CustomLocalDateTimeSerializer());

    return new Jackson2ObjectMapperBuilder().featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).findModulesViaServiceLoader(true)
            .modulesToInstall(module);
}
 
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:14,代码来源:JacksonConfiguration.java


注:本文中的com.fasterxml.jackson.datatype.jsr310.JavaTimeModule.addDeserializer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。