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
JacksonConverter( 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
suspend fun convertForReceive( Convert a value (RAW or intermediate) from receive pipeline (deserialize). Pipeline PipelineContext.subject has ApplicationReceiveRequest.value of type ByteReadChannel |
|
suspend fun convertForSend( Convert a value to the specified contentType to a value suitable for sending (serialize).
Note that as far as ContentConverter could be registered multiple times with different content types
hence contentType could be different depends on what the client accepts (inferred from Accept header).
This function could ignore value if it is not suitable for conversion and return |