ktor-jackson / io.ktor.jackson / JacksonConverter

JacksonConverter

class JacksonConverter : ContentConverter
    install(ContentNegotiation) {
       register(ContentType.Application.Json, JacksonConverter())
    }

    to be able to modify the objectMapper (eg. using specific modules and/or serializers and/or
    configuration options, you could use the following (as seen in the ktor-samples):

    install(ContentNegotiation) {
        jackson {
            configure(SerializationFeature.INDENT_OUTPUT, true)
            registerModule(JavaTimeModule())

Constructors

<init>

JacksonConverter(objectmapper: ObjectMapper = jacksonObjectMapper())
    install(ContentNegotiation) {
       register(ContentType.Application.Json, JacksonConverter())
    }

    to be able to modify the objectMapper (eg. using specific modules and/or serializers and/or
    configuration options, you could use the following (as seen in the ktor-samples):

    install(ContentNegotiation) {
        jackson {
            configure(SerializationFeature.INDENT_OUTPUT, true)
            registerModule(JavaTimeModule())

Functions

convertForReceive

suspend fun convertForReceive(context: PipelineContext<ApplicationReceiveRequest, ApplicationCall>): Any?

convertForSend

suspend fun convertForSend(context: PipelineContext<Any, ApplicationCall>, contentType: ContentType, value: Any): Any?