KotlinxSerializationJsonSerializer

@ExperimentalSerializationApi
class KotlinxSerializationJsonSerializer(jsonFormat: Json) : JsonSerializer

A JsonSerializer for integrating with kotlinx.serialization.

CAVEAT: This class uses experimental Kotlin Serialization APIs, and only works with non-nullable types. We plan to lift these limitations after kotlinx.serialization issue 1348 is resolved.

In the meantime, if you prefer not to rely on experimental APIs, or if you must read or write a nullable type, we advise doing the serialization "manually" as shown in the following sample. Note that you can still make KotlinxSerializationJsonSerializer the default serializer, and override the serialization for nullable types as needed.

Samples

Constructors

Link copied to clipboard
fun KotlinxSerializationJsonSerializer(jsonFormat: Json = Json)

Functions

Link copied to clipboard
open override fun <T> deserialize(json: ByteArray, type: TypeRef<T>): T
Link copied to clipboard
open override fun <T> serialize(value: T, type: TypeRef<T>): ByteArray