Ktor 1.4.0 Help

Json

Processes the request and the response payload as JSON, serializing and de-serializing them using a specific serializer: JsonSerializer.

val client = HttpClient(HttpClientEngine) { install(JsonFeature) }

You have a full example using JSON.

Serializers

The JsonFeature has a default serializer(implicitly obtained or by calling defaultSerializer()) based on a ServiceLoader on JVM(supporting Gson or Jackson depending on the artifact included), and a serializer based on kotlinx.serialization for Native as well as for JavaScript.

You can also get the default serializer by calling io.ktor.client.features.json.defaultSerializer()

Gson

val client = HttpClient(HttpClientEngine) { install(JsonFeature) { serializer = GsonSerializer() } }

Jackson

val client = HttpClient(HttpClientEngine) { install(JsonFeature) { serializer = JacksonSerializer() } }

Kotlinx.Serialization

val client = HttpClient(HttpClientEngine) { install(JsonFeature) { serializer = KotlinxSerializer() } }
Last modified: 04 September 2020