Interface JsonConfig
public interface JsonConfig
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAllows parser to accept C/Java-style comments in JSON input.booleanRemoves JSON specification restriction on special floating-point values such as `NaN` and `Infinity` and enables their serialization and deserialization.booleanEnables 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]`.booleanSpecifies if trailing comma is allowed.Name of the class descriptor property for polymorphic serialization.booleanEnables coercing incorrect JSON values to the default property value in the following cases: 1.booleanSpecifies if the enum values should be decoded case insensitively.booleanSpecifies whether default values of Kotlin properties should be encoded.booleanSpecifies whether `null` values should be encoded for nullable properties and must be present in JSON object during decoding.booleanSpecifies whether encounters of unknown properties in the input JSON should be ignored instead of throwing [SerializationException].booleanRemoves JSON specification restriction (RFC-4627) and makes parser more liberal to the malformed input.Specifies theJsonNamingStrategythat should be used for all properties in classes for serialization and deserialization.booleanSpecifies whether resulting JSON should be pretty-printed.Specifies indent string to use with [prettyPrint] modebooleanSpecifies whether Json instance makes use of [JsonNames] annotation.booleanSwitches polymorphic serialization to the default array format.
-
Method Details
-
allowSpecialFloatingPointValues
@WithDefault("false") 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
@WithDefault("false") 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
Name of the class descriptor property for polymorphic serialization. -
coerceInputValues
@WithDefault("false") 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
@WithDefault("true") boolean encodeDefaults()Specifies whether default values of Kotlin properties should be encoded. -
explicitNulls
@WithDefault("true") 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.
trueby default. -
ignoreUnknownKeys
@WithDefault("false") boolean ignoreUnknownKeys()Specifies whether encounters of unknown properties in the input JSON should be ignored instead of throwing [SerializationException]. -
isLenient
@WithDefault("false") 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
@WithDefault("false") boolean prettyPrint()Specifies whether resulting JSON should be pretty-printed. -
prettyPrintIndent
Specifies indent string to use with [prettyPrint] mode -
useAlternativeNames
@WithDefault("true") 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
@WithDefault("false") 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
Specifies theJsonNamingStrategythat should be used for all properties in classes for serialization and deserialization. This strategy is applied for all entities that haveStructureKind.CLASS.nullby default.This element can be one of two things:
- the fully qualified class name of a type implements the
NamingStrategyinterface and has a no-arg constructor - a value in the form
NamingStrategy.SnakeCasewhich refers to built-in values provided by the kotlin serialization library itself.
- the fully qualified class name of a type implements the
-
decodeEnumsCaseInsensitive
@WithDefault("false") boolean decodeEnumsCaseInsensitive()Specifies if the enum values should be decoded case insensitively. -
allowTrailingComma
@WithDefault("false") boolean allowTrailingComma()Specifies if trailing comma is allowed. -
allowComments
@WithDefault("false") boolean allowComments()Allows parser to accept C/Java-style comments in JSON input.
-