zoukankan      html  css  js  c++  java
  • Features for configuring JSON-to-Java mapping

    Following on/off features are defined in DeserializationConfig.Feature (Jackson 1.x) or DeserializationFeature (Jackson 2.x):

    ACCEPT_EMPTY_STRING_AS_NULL_OBJECT (default: false) (since 1.8)

    Determines whether empty JSON String value is accepted as null value for regular POJOs ("beans") with data-binding: this can be useful when dealing endpoints written in a language that has loose typing and may represent missing objects as Empty Strings.

    ACCEPT_SINGLE_VALUE_AS_ARRAY

    Allows auto-conversion from non-JSON-array values to single-element arrays and Collections (adding implicit "array wrapper"): this is sometimes necessary for interoperability, as some libraries and frameworks omit JSON arrays when serializing single-element arrays.

    AUTO_DETECT_CREATORS (default: true)

    Controls whether potential creator methods (public single-argument constructors, public static methods that return instance of class itself (aka factory methods)) can be automatically detected without being annotated with @JsonCreator (or similar for alternate annotation introspector).

    AUTO_DETECT_FIELDS (default: true)

    Similar to AUTO_DETECT_SETTERS, controls whether public instance fields are recognized as deserializable properties.

    AUTO_DETECT_SETTERS (default: true)

    Controls whether "setter" methods are automatically detected (as opposed to located by annotations); if enabled, non-private single-argument non-static methods are recognized as setters (method used to set value of the logical property). If disabled, only ones explicitly annotated (using @JsonProperty, for example) are recognized as deserializable properties

    CAN_OVERRIDE_ACCESS_MODIFIERS (default: true)

    Whether non-public fields and methods can be forced accessible (using JDK provided methods or not): if disabled, non-public fields and methods can not be used for properties.

    The main reason to disable this feature is if running on a security-restricted platform where trying to change access rights results in a runtime error.

    FAIL_ON_INVALID_SUBTYPE (default: true) (since 2.2)

    Determines what happens when type information for polymorphic types (see @JsonTypeInfo) is either missing or invalid (unmappable); if enabled, exception is thrown; if disabled, null reference is used instead (as type can not be determined).

    FAIL_ON_NULL_FOR_PRIMITIVES (default: false) (since 1.7)

    Determines whether JSON null is acceptable for Java primitive types (intbooleandouble etc); if set to 'false', default value is used; if 'true', a JsonProcessingException will be thrown.

    FAIL_ON_NUMBERS_FOR_ENUMS (default: false) (since 1.7)

    Determines whether JSON integer numbers (0, 1, 2, ...) can be deserialized into Java Enum types; if set to 'false', this is legal and value is used to deserialize value that matches Enum.ordinal(); if 'true', trying to deserialize JSON number into Enum throws a JsonProcessingException

    FAIL_ON_UNKNOWN_PROPERTIES (default: true) (since 1.2)

    Used to control whether encountering of unknown properties (one for which there is no setter; and there is no fallback "any setter" method defined using @JsonAnySetter annotation) should result in a JsonMappingException (when enabled), or just quietly ignored (when disabled)

    READ_ENUMS_USING_TO_STRING (default: false) (since 1.6)

    Determines which method is used to determine expected serialization of an Enum: if false (default), use Enum.name(); if true, Enum.toString().

    USE_ANNOTATIONS (default: true) (since 1.2)

    Controls whether any annotation introspection is used for configuring data binding: if disabled, all annotations are ignored (independent of setting for AnnotationIntrospector in use)

    note: since 1.8, disable this feature will try to remove ALL annotation processing; this to help on platforms like Android, where trying to access unavailable annotation types (JAXB annotations for value types) can result in exception, even if not specifically looking for that annotation type.

    USE_BIG_DECIMAL_FOR_FLOATS (default: false)

    Controls whether java.math.BigDecimal is used for deserializing JSON floating point numbers, when resulting type is a generic type (java.lang.Object) or generic number type (java.lang.Number); if disabled type will be java.lang.Double

    Does not affect explicit type (i.e. if expected result type is java.lang.Double or such)

    USE_BIG_INTEGER_FOR_INTS (default: false)

    Similar to USE_BIG_DECIMAL_FOR_FLOATS, but used when value to map is a JSON integer number (numeric value without decimal point). If enabled, type java.math.BigInteger is used for binding to generic types; if disabled, java.lang.Integer or java.lang.Long is used (smallest applicable type that can contain actual value)

    USE_GETTERS_AS_SETTERS (default: true)

    Controls whether "getters" that return Collection or Map types can be used for "setting" values (same as how JAXB API works with XML), so that separate "setter" method is not needed.

    Even if enabled, explicit "setter" method will have precedence over implicit getter-as-setter, if one exists.

    USE_JAVA_ARRAY_FOR_JSON_ARRAY (default: false) (since 1.9)

    Determines whether to bind JSON Arrays as java.util.Lists or Object[] instances, when binding to nominal type of java.lang.Object: if disabled, as List, if enabled as Object[].

  • 相关阅读:
    uniapp 常用的基础知识
    uniapp接口请求(第一种)
    系统对象的使用——Cookie,ViewState,Session,Application
    网页跳转
    存储过程的使用——游标
    存储过程的使用——循环,条件语句
    存储过程的使用——定义变量
    页面读取英语单词
    加密
    XMind: ZEN 快捷键
  • 原文地址:https://www.cnblogs.com/huey/p/5626974.html
Copyright © 2011-2022 走看看