json

fun Configuration.json(json: Json = DefaultJson, contentType: ContentType = ContentType.Application.Json)

Registers the application/json (or another specified contentType) content type to the ContentNegotiation plugin using kotlinx.serialization.

The example below shows how to register the JSON serializer with customized serialization settings provided by JsonBuilder:

install(ContentNegotiation) {
json(Json {
prettyPrint = true
isLenient = true
})
}

You can learn more from Content negotiation and serialization.

Parameters

json

a format instance (optional)

contentType

to register with, application/json by default