DateTimeSerializer:什么是参数shapeOverride?

时间:2018-02-09 12:10:44

标签: serialization jackson jodatime fasterxml

com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer#DateTimeSerializer(JacksonJodaDateFormat format,int shapeOverride)

我无法弄清楚shapeOverride的含义。无法在互联网上找到有关它的适当信息。那它是什么意思,它的用途是什么?

1 个答案:

答案 0 :(得分:0)

这提示杰克逊告诉它“形状”字段是什么。形状基本上是数据类型。我不知道您是否曾经序列化过Joda对象并获​​得了数组,但这基本上是形状。

是数组,字符串还是时间戳?

替代值是任何非0值。因此,如果您提供0,则会得到默认值,默认值为ARRAY。

因此,根据您要序列化数据的方式传递以下信息:

  • 无替代= 0
  • STRING = 1
  • TIMESTAMP = 2
  • ARRAY = 3

您可以在com.fasterxml.jackson.datatype.joda.ser.JodaDateSerializerBase中看到它们的爆炸声

    public abstract class JodaDateSerializerBase<T> extends JodaSerializerBase<T>
    // need contextualization to read per-property annotations
        implements ContextualSerializer
    {
        private static final long serialVersionUID = 1L;

        // // Since 2.9

        protected final static int FORMAT_STRING = 1;
        protected final static int FORMAT_TIMESTAMP = 2;
        protected final static int FORMAT_ARRAY = 3;

        protected final JacksonJodaDateFormat _format;

        protected final SerializationFeature _featureForNumeric;

        /**
        * Shape to use for generic "use numeric" feature (instead of more specific
        * JsonFormat.shape).
        *
        * @since 2.9
        */
        protected final int _defaultNumericShape;

        /**
        * Marker set to non-0 if (and only if) property or type override exists.
        *
        * @since 2.9
        */
        protected final int _shapeOverride;