Class JsonConfig


  • public class JsonConfig
    extends Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean allowSpecialFloatingPointValues
      Removes JSON specification restriction on special floating-point values such as `NaN` and `Infinity` and enables their serialization and deserialization.
      boolean allowStructuredMapKeys
      Enables structured objects to be serialized as map keys by changing serialized form of the map from JSON object (key-value pairs) to flat array like `[k1, v1, k2, v2]`.
      boolean allowTrailingComma
      Specifies if trailing comma is allowed.
      String classDiscriminator
      Name of the class descriptor property for polymorphic serialization.
      boolean coerceInputValues
      Enables coercing incorrect JSON values to the default property value in the following cases: 1.
      boolean decodeEnumsCaseInsensitive
      Specifies if the enum values should be decoded case insensitively.
      boolean encodeDefaults
      Specifies whether default values of Kotlin properties should be encoded.
      boolean explicitNulls
      Specifies whether `null` values should be encoded for nullable properties and must be present in JSON object during decoding.
      boolean ignoreUnknownKeys
      Specifies whether encounters of unknown properties in the input JSON should be ignored instead of throwing [SerializationException].
      boolean isLenient
      Removes JSON specification restriction (RFC-4627) and makes parser more liberal to the malformed input.
      Optional<String> namingStrategy
      Specifies the JsonNamingStrategy that should be used for all properties in classes for serialization and deserialization.
      boolean prettyPrint
      Specifies whether resulting JSON should be pretty-printed.
      String prettyPrintIndent
      Specifies indent string to use with [prettyPrint] mode
      boolean useAlternativeNames
      Specifies whether Json instance makes use of [JsonNames] annotation.
      boolean useArrayPolymorphism
      Switches polymorphic serialization to the default array format.
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonConfig()  
    • Field Detail

      • allowSpecialFloatingPointValues

        @ConfigItem(defaultValue="false")
        public boolean allowSpecialFloatingPointValues
        Removes JSON specification restriction on special floating-point values such as `NaN` and `Infinity` and enables their serialization and deserialization. When enabling it, please ensure that the receiving party will be able to encode and decode these special values.
      • allowStructuredMapKeys

        @ConfigItem(defaultValue="false")
        public boolean allowStructuredMapKeys
        Enables structured objects to be serialized as map keys by changing serialized form of the map from JSON object (key-value pairs) to flat array like `[k1, v1, k2, v2]`.
      • classDiscriminator

        @ConfigItem(defaultValue="type")
        public String classDiscriminator
        Name of the class descriptor property for polymorphic serialization.
      • coerceInputValues

        @ConfigItem(defaultValue="false")
        public boolean coerceInputValues
        Enables coercing incorrect JSON values to the default property value in the following cases: 1. JSON value is `null` but property type is non-nullable. 2. Property type is an enum type, but JSON value contains unknown enum member.
      • encodeDefaults

        @ConfigItem(defaultValue="true")
        public boolean encodeDefaults
        Specifies whether default values of Kotlin properties should be encoded.
      • explicitNulls

        @ConfigItem(defaultValue="true")
        public boolean explicitNulls
        Specifies whether `null` values should be encoded for nullable properties and must be present in JSON object during decoding.

        When this flag is disabled properties with `null` values without default are not encoded; during decoding, the absence of a field value is treated as `null` for nullable properties without a default value.

        true by default.

      • ignoreUnknownKeys

        @ConfigItem(defaultValue="false")
        public boolean ignoreUnknownKeys
        Specifies whether encounters of unknown properties in the input JSON should be ignored instead of throwing [SerializationException].
      • isLenient

        @ConfigItem(defaultValue="false")
        public boolean isLenient
        Removes JSON specification restriction (RFC-4627) and makes parser more liberal to the malformed input. In lenient mode quoted boolean literals, and unquoted string literals are allowed.

        Its relaxations can be expanded in the future, so that lenient parser becomes even more permissive to invalid value in the input, replacing them with defaults.

      • prettyPrint

        @ConfigItem(defaultValue="false")
        public boolean prettyPrint
        Specifies whether resulting JSON should be pretty-printed.
      • prettyPrintIndent

        @ConfigItem(defaultValue="    ")
        public String prettyPrintIndent
        Specifies indent string to use with [prettyPrint] mode
      • useAlternativeNames

        @ConfigItem(defaultValue="true")
        public boolean useAlternativeNames
        Specifies whether Json instance makes use of [JsonNames] annotation.

        Disabling this flag when one does not use [JsonNames] at all may sometimes result in better performance, particularly when a large count of fields is skipped with [ignoreUnknownKeys].

      • useArrayPolymorphism

        @ConfigItem(defaultValue="false")
        public boolean useArrayPolymorphism
        Switches polymorphic serialization to the default array format. This is an option for legacy JSON format and should not be generally used.
      • namingStrategy

        @ConfigItem(name="naming-strategy")
        public Optional<String> namingStrategy
        Specifies the JsonNamingStrategy that should be used for all properties in classes for serialization and deserialization. This strategy is applied for all entities that have StructureKind.CLASS.

        null by default.

        This element can be one of two things:

        1. the fully qualified class name of a type implements the NamingStrategy interface and has a no-arg constructor
        2. a value in the form NamingStrategy.SnakeCase which refers to built-in values provided by the kotlin serialization library itself.
      • decodeEnumsCaseInsensitive

        @ConfigItem(defaultValue="false")
        public boolean decodeEnumsCaseInsensitive
        Specifies if the enum values should be decoded case insensitively.
      • allowTrailingComma

        @ConfigItem(defaultValue="false")
        public boolean allowTrailingComma
        Specifies if trailing comma is allowed.
    • Constructor Detail

      • JsonConfig

        public JsonConfig()