ktor-serialization / io.ktor.serialization / SerializationConverter

SerializationConverter

class SerializationConverter : ContentConverter

ContentConverter with kotlinx.serialization.

Installation:

install(ContentNegotiation) {
   json()
   json(ContentType.Application.Json, Json.nonstrict)
   cbor()
   protoBuf()
}

Constructors

<init>

SerializationConverter(format: BinaryFormat)

Creates a converter serializing with the specified binary format.

SerializationConverter(format: StringFormat, defaultCharset: <ERROR CLASS> = Charsets.UTF_8)

Creates a converter serializing with the specified string format and defaultCharset (optional, usually it is UTF-8).

SerializationConverter(json: Json = DefaultJson)SerializationConverter()

This is no longer supported. Instead, specify format explicitly or use the corresponding DSL function.

Functions

convertForReceive

suspend fun convertForReceive(context: PipelineContext<ApplicationReceiveRequest, ApplicationCall>): Any?

convertForSend

suspend fun convertForSend(context: PipelineContext<Any, ApplicationCall>, contentType: ContentType, value: Any): Any?