AnyValueSerializer

Serializer that encodes Any? type using AnyValueSurrogate.

It should primarily be used to serialize values inside collection types.

usage:

// as type annotation
val customValues: MutableMap
// or directly with other serializers
val serializer = MapSerializer(String.serializer(), AnyValueSerializer)

example JSON output:

val myMap = mutableMapOf("hello" to "world", "foo" to null)
println(Json.encodeToString(myMap))
// >> {"hello":{"type":"java.lang.String","value":"world"},"foo":null}

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): Any?
Link copied to clipboard
open override fun serialize(encoder: Encoder, value: Any?)