so here we create a common mapper to be used by our application:
val mapper: ObjectMapper = jacksonObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
then we set it as a part of content negotiation feature
install(ContentNegotiation) {
register(ContentType.Application.Json, JacksonConverter(mapper))
}
however, we are unable to use the same mapper for HttpClient
val defaultHttpClient = HttpClient(OkHttp) {
expectSuccess = false
install(JsonFeature) {
this.serializer = JacksonSerializer {
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
setSerializationInclusion(JsonInclude.Include.NON_NULL)
}
}
engine {
config {
readTimeout(Duration.ofMillis(2000))
connectTimeout(Duration.ofMillis(5000))
connectionPool(ConnectionPool(100, 1, TimeUnit.MINUTES))
}
}
}