JsonBuilder

Builder of the Json instance provided by Json { ... } factory function:

val json = Json { // this: JsonBuilder
encodeDefaults = true
ignoreUnknownKeys = true
}

Properties

Link copied to clipboard

Allows parser to accept C/Java-style comments in JSON input.

Link copied to clipboard

Removes JSON specification restriction on special floating-point values such as NaN and Infinity and enables their serialization and deserialization as float literals without quotes. When enabling it, please ensure that the receiving party will be able to encode and decode these special values. This option affects both encoding and decoding. false by default.

Link copied to clipboard

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]. false by default.

Link copied to clipboard

Allows parser to accept trailing (ending) commas in JSON objects and arrays, making inputs like [1, 2, 3,] and {"key": "value",} valid. Does not affect encoding. false by default.

Link copied to clipboard

Name of the class descriptor property for polymorphic serialization. type by default.

Link copied to clipboard

Defines which classes and objects should have class discriminator added to the output. ClassDiscriminatorMode.POLYMORPHIC by default.

Link copied to clipboard

Enables coercing incorrect JSON values in the following cases:

Link copied to clipboard

Enables decoding enum values in a case-insensitive manner. Encoding is not affected by this option.

Link copied to clipboard

Specifies whether default values of Kotlin properties should be encoded. false by default.

Link copied to clipboard

Specifies whether null values should be encoded for nullable properties and must be present in JSON object during decoding.

Link copied to clipboard

Specifies whether encounters of unknown properties in the input JSON should be ignored instead of throwing SerializationException. false by default.

Link copied to clipboard

Removes JSON specification restriction (RFC-4627) and makes parser more liberal to the malformed input. In lenient mode, unquoted JSON keys and string values are allowed.

Link copied to clipboard

Specifies JsonNamingStrategy that should be used for all properties in classes for serialization and deserialization.

Link copied to clipboard

Specifies whether resulting JSON should be pretty-printed: formatted and optimized for human readability. false by default.

Link copied to clipboard

Specifies indent string to use with prettyPrint mode. Only whitespace characters are allowed: ' ', '\n', '\r' or '\t'. 4 spaces by default.

Link copied to clipboard

Module with contextual and polymorphic serializers to be used in the resulting Json instance.

Link copied to clipboard

Specifies whether Json instance makes use of JsonNames annotation.

Link copied to clipboard

Switches polymorphic serialization to the default array format. This is an option for legacy JSON format and should not be generally used. false by default.