Using:
- spring boot 2.7.18
- JDK 17.0.10
When I map a RequestBody to a Java-enum, then KotlinSerializationJsonHttpMessageConverter takes precedence over the Jackson HttpMessageConverter. Although this is not what i'd prefer, it works in most cases, unless that enum contains an @jsonvalue to specify a different mapping. Then I get following exception:
HttpMessageNotReadableException: Could not read JSON: Unexpected JSON token at offset 0: Expected quotation mark '"', but had 't' instead at path: $
JSON input: test; nested exception is kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected quotation mark '"', but had 't' instead at path: $
@RestController
public class TestController {
@PostMapping(value = "/api/test")
public Object post(@RequestBody TestEnum testEnum) {
return testEnum;
}
}
public enum TestEnum {
TEST("test");
@JsonValue
@Getter
private String value;
TestEnum(String value) {
this.value = value;
}
}
Using:
When I map a RequestBody to a Java-enum, then KotlinSerializationJsonHttpMessageConverter takes precedence over the Jackson HttpMessageConverter. Although this is not what i'd prefer, it works in most cases, unless that enum contains an @jsonvalue to specify a different mapping. Then I get following exception:
HttpMessageNotReadableException: Could not read JSON: Unexpected JSON token at offset 0: Expected quotation mark '"', but had 't' instead at path: $
JSON input: test; nested exception is kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected quotation mark '"', but had 't' instead at path: $