You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Configure Kotlin JSON converters as Jackson alternative
Prior to this commit, Spring MVC and WebFlux would consider the
"kotlinx.serialization" JSON codecs and converters in addition to other
JSON alternatives like Jackson, Gson and Jsonb.
This would cause issues because while in most cases this library is only
involved if the type is annotated with "@serializable", this is not true
for Java enums. In this particular case, the codec shadows Jackson and
causes issues.
This commit now considers kotlinx.serialization JSON support as an
alternative to Jackson. Just like Jsonb and GSON, this is only
auto-detected if Jackson is not present.
We received consistent feedback that kotlinx.serialization is popular in
Kotlin libraries and is often a transitive dependency. As a result, we
cannot consider its presence on the classpath as a strong enough signal
to configure it by default.
Closesgh-34410
Copy file name to clipboardExpand all lines: framework-docs/modules/ROOT/pages/web/webmvc/message-converters.adoc
+5
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,11 @@ You can customize XML mapping as needed through the use of JAXB or Jackson's pro
54
54
When you need further control (for cases where custom XML serializers/deserializers need to be provided for specific types), you can inject a custom `XmlMapper` through the `ObjectMapper` property.
55
55
By default, this converter supports `application/xml`. This requires the `com.fasterxml.jackson.dataformat:jackson-dataformat-xml` dependency.
56
56
57
+
| `KotlinSerializationJsonHttpMessageConverter`
58
+
| An `HttpMessageConverter` implementation that can read and write JSON using `kotlinx.serialization`.
59
+
This converter is not configured by default, as this conflicts with Jackson.
60
+
Developers must configure it as an additional converter ahead of the Jackson one.
Copy file name to clipboardExpand all lines: spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java
Copy file name to clipboardExpand all lines: spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java
Copy file name to clipboardExpand all lines: spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
0 commit comments