Class JacksonHelper

java.lang.Object
cool.scx.common.jackson.JacksonHelper

public final class JacksonHelper extends Object
JacksonHelper
Version:
0.0.1
Author:
scx567888
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <M extends com.fasterxml.jackson.databind.ObjectMapper, B extends com.fasterxml.jackson.databind.cfg.MapperBuilder<M,B>>
    M
    createObjectMapper(com.fasterxml.jackson.databind.cfg.MapperBuilder<M,B> mapperBuilder, BuildOptions o)
    根据 MapperBuilder 获取 ObjectMapper 对象 并对默认属性进行一些设置,具体如下 如需获得原始的 ObjectMapper 对象请使用 MapperBuilder; 自行创建 1, 针对 日期 类型设置 自定义的格式 MyJavaTimeModule 2, DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES 设置为 false 3, SerializationFeature.FAIL_ON_EMPTY_BEANS 设置为 false 4, NullKeySerializer 设置为 JacksonHelper.NULL_KEY_SERIALIZER

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JacksonHelper

      public JacksonHelper()
  • Method Details

    • createObjectMapper

      public static <M extends com.fasterxml.jackson.databind.ObjectMapper, B extends com.fasterxml.jackson.databind.cfg.MapperBuilder<M,B>> M createObjectMapper(com.fasterxml.jackson.databind.cfg.MapperBuilder<M,B> mapperBuilder, BuildOptions o)
      根据 MapperBuilder 获取 ObjectMapper 对象 并对默认属性进行一些设置,具体如下 如需获得原始的 ObjectMapper 对象请使用 MapperBuilder; 自行创建 1, 针对 日期 类型设置 自定义的格式 MyJavaTimeModule 2, DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES 设置为 false 3, SerializationFeature.FAIL_ON_EMPTY_BEANS 设置为 false 4, NullKeySerializer 设置为 JacksonHelper.NULL_KEY_SERIALIZER
      Type Parameters:
      M - a M class
      B - a B class
      Parameters:
      mapperBuilder - a MapperBuilder object
      Returns:
      a ObjectMapper object