ktor-client-json / io.ktor.client.features.json / JsonFeature

JsonFeature

class JsonFeature
Deprecated: Please use ContentNegotiation feature

HttpClient feature that serializes/de-serializes as JSON custom objects to request and from response bodies using a serializer.

The default serializer is GsonSerializer.

The default acceptContentTypes is a list which contains ContentType.Application.Json

Note: It will de-serialize the body response if the specified type is a public accessible class and the Content-Type is one of acceptContentTypes list (application/json by default).

Types

Config

class Config

JsonFeature configuration that is used during installation

Feature

companion object Feature : HttpClientFeature<Config, JsonFeature>

Companion object for feature installation

Constructors

<init>

JsonFeature(serializer: JsonSerializer)

Properties

acceptContentTypes

val acceptContentTypes: List<ContentType>

that are allowed when receiving content

serializer

val serializer: JsonSerializer

that is used to serialize and deserialize request/response bodies

Companion Object Properties

key

val key: AttributeKey<JsonFeature>

Companion Object Functions

install

fun install(feature: JsonFeature, scope: HttpClient): Unit

prepare

fun prepare(block: Config.() -> Unit): JsonFeature