I try to configure `KotlinSerializationJsonEncoder...
# spring
m
I try to configure
KotlinSerializationJsonEncoder
in my
SpringBoot
app. have maybe somebody a
hint
what is wrong in my configuration …. I get the following exception when I call my backend service.
Copy code
org.springframework.web.reactive.function.client.WebClientResponseException: 200 OK from UNKNOWN ; nested exception is kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 7: Encountered an unknown key 'fooBar'.
Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.
JSON input: {
    "fooBar": "123,345.....
I try to configured it like this:
Copy code
@Configuration
class WebConfig : WebFluxConfigurer {
    //<https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#webflux-config-message-codecs>
    override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
        KotlinSerializationJsonEncoder(
            Json {
                ignoreUnknownKeys = true
            }
        )
    }
}
the Good thing is the Jackson gone when I check my stacktrace 🙂
j
Copy code
override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
        KotlinSerializationJsonEncoder(
            Json {
                ignoreUnknownKeys = true
            }
        )
    }
I don’t think that this has any effect, as in neither a value is returned nor the configurer is used
🙈 1
🙏 1