當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。