JsonBuilder

class JsonBuilder

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

Properties

Link copied to clipboard
var allowSpecialFloatingPointValues: Boolean

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

Link copied to clipboard
var allowStructuredMapKeys: Boolean

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
var classDiscriminator: String

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

Link copied to clipboard
var coerceInputValues: Boolean

Enables coercing incorrect JSON values to the default property value in the following cases:

Link copied to clipboard
var encodeDefaults: Boolean

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

Link copied to clipboard
var explicitNulls: Boolean

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

Link copied to clipboard
var ignoreUnknownKeys: Boolean

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

Link copied to clipboard
var isLenient: Boolean

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.

Link copied to clipboard
var prettyPrint: Boolean

Specifies whether resulting JSON should be pretty-printed. false by default.

Link copied to clipboard
var prettyPrintIndent: String

Specifies indent string to use with prettyPrint mode 4 spaces by default. Experimentality note: this API is experimental because it is not clear whether this option has compelling use-cases.

Link copied to clipboard
var serializersModule: SerializersModule

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

Link copied to clipboard
var useAlternativeNames: Boolean

Specifies whether Json instance makes use of JsonNames annotation.

Link copied to clipboard
var useArrayPolymorphism: Boolean

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.