JsonFormat

class JsonFormat<T>(serializer: KSerializer<T>) : BodyFormat<T>

A BodyFormat that uses JsonSerializer to encode and decode values.

Parameters

serializer

The KSerializer to use for encoding and decoding.

Type Parameters

T

The type of the body to encode/decode.

Constructors

Link copied to clipboard
constructor(serializer: KSerializer<T>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val contentType: String

The content type of the body.

Link copied to clipboard
open override val serialization: JsonSerializer

The serialization engine that produced this format, if any.

Functions

Link copied to clipboard
open override fun decode(bytes: ByteArray, contentType: String): T

Decodes the byte array into the type T.

Link copied to clipboard
open override fun encode(value: T): ByteArray

Encodes the value into a byte array for transmission.