marzelwidmer
06/17/2021, 2:59 PMKotlinSerializationJsonEncoder
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.
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:
@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
}
)
}
}
marzelwidmer
06/17/2021, 3:00 PMJonas Bark
06/17/2021, 3:14 PMoverride 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