Add kotlinx.serialization JSON support to Spring MVC

Closes gh-21188

Co-authored-by: Sebastien Deleuze <sdeleuze@vmware.com>
This commit is contained in:
Andreas Ahlenstorf
2020-01-27 13:59:16 +01:00
committed by Sébastien Deleuze
parent b8c12a3aa1
commit cd6085a310
8 changed files with 495 additions and 1 deletions

View File

@@ -383,10 +383,24 @@ class KotlinScriptConfiguration {
}
----
See the https://github.com/sdeleuze/kotlin-script-templating[kotlin-script-templating] example
project for more details.
=== Kotlin multiplatform serialization
As of Spring Framework 5.3, https://github.com/Kotlin/kotlinx.serialization[Kotlin multiplatform serialization] is
supported in Spring MVC. The builtin support currently only targets JSON format.
To enable it, follow https://github.com/Kotlin/kotlinx.serialization#setup[those instructions] and make sure neither
Jackson, GSON or JSONB are in the classpath.
NOTE: For a typical Spring Boot web application, that can be achieved by excluding `spring-boot-starter-json` dependency.
If you need Jackson, GSON or JSONB for other purposes, you can keep them on the classpath and
<<web#mvc-config-message-converters, configure message converters>> to remove `MappingJackson2HttpMessageConverter` and add
`KotlinSerializationJsonHttpMessageConverter`.
== Coroutines
Kotlin https://kotlinlang.org/docs/reference/coroutines-overview.html[Coroutines] are Kotlin