Package io.ktor.serialization

Types

Link copied to clipboard
interface Configuration

Configuration for client and server ContentNegotiation plugin

Link copied to clipboard
interface ContentConverter

A custom content converter that could be registered in ContentNegotiation plugin for any particular content type Could provide bi-directional conversion implementation. One of the most typical examples of content converter is a JSON content converter that provides both serialization and deserialization

Link copied to clipboard
open class ContentConvertException(message: String, cause: Throwable?) : Exception
Link copied to clipboard
class JsonConvertException(message: String, cause: Throwable?) : ContentConvertException
Link copied to clipboard
interface WebsocketContentConverter

A custom content converter that could be used in the WebSockets plugin Could provide bi-directional conversion implementation. One of the most typical examples of the content converter is a JSON converter that provides both serialization and deserialization

Link copied to clipboard
open class WebsocketContentConvertException(message: String, cause: Throwable?) : ContentConvertException
Link copied to clipboard
class WebsocketConverterNotFoundException(message: String, cause: Throwable?) : WebsocketContentConvertException
Link copied to clipboard
class WebsocketDeserializeException(message: String, cause: Throwable?, frame: Frame) : WebsocketContentConvertException

Functions

Link copied to clipboard
inline suspend fun <T> WebsocketContentConverter.deserialize(content: Frame, charset: Charset = Charsets.UTF_8): T

Deserializes content to the value of type T

Link copied to clipboard
inline suspend fun <T> WebsocketContentConverter.serialize(value: T, charset: Charset = Charsets.UTF_8): Frame

Serializes a value to a WebSocket Frame. This function could throw WebsocketConverterNotFoundException if the value is not suitable for conversion

Link copied to clipboard
fun Headers.suitableCharset(defaultCharset: Charset = Charsets.UTF_8): Charset

Detect suitable charset for an application call by Accept header or fallback to defaultCharset

Link copied to clipboard
fun Headers.suitableCharsetOrNull(defaultCharset: Charset = Charsets.UTF_8): Charset?

Detect suitable charset for an application call by Accept header or fallback to null