kotlinx-serialization / kotlinx.serialization.json / JsonConfiguration / <init>
<init>
(common, js, jvm, native) <init>(encodeDefaults: Boolean = true, ignoreUnknownKeys: Boolean = false, isLenient: Boolean = false, serializeSpecialFloatingPointValues: Boolean = false, allowStructuredMapKeys: Boolean = false, prettyPrint: Boolean = false, unquotedPrint: Boolean = false, indent: String = defaultIndent, useArrayPolymorphism: Boolean = false, classDiscriminator: String = defaultDiscriminator, updateMode: UpdateMode = UpdateMode.OVERWRITE)
The class responsible for JSON-specific customizable behaviour in Json format.
Options list:
- encodeDefaults specifies whether default values are encoded.
- ignoreUnknownKeys ignores encounters of unknown properties in the input JSON.
- 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.
- serializeSpecialFloatingPointValues removes JSON specification restriction on
special floating-point values such as
NaN
and Infinity
and enables their
serialization. When enabling it, please ensure that the receiving party will be
able to parse these special values.
- unquotedPrint specifies whether keys and values should be quoted when building the
JSON string. This option is intended to be used for debugging and pretty-printing,
enabling it in the production code is not recommended as strings produced with
this setting are not valid JSON. String values containing whitespaces and delimiter characters
will be quoted anyway.
- allowStructuredMapKeys enables structured objects to be serialized as map keys by
changing serialized form of the map from JSON object (kv pairs) to flat array
[k1, v1, k2, v2]
.
- prettyPrint specifies whether resulting JSON should be pretty-printed.
- indent specifies indent string to use with prettyPrint mode.
- useArrayPolymorphism switches polymorphic serialization to the default array format.
This is an option for legacy JSON format and should not be generally used.
- classDiscriminator name of the class descriptor property in polymorphic serialization.
This class is marked with UnstableDefault: its semantics may be changes in the next releases, e.g.
additional flag may be introduced or default parameter values may be changed.