This pull requests adds HttpMessageConverter
s for kotlinx.serialization that support application/json
and application/cbor
. Tests are included but written in Kotlin because @Serializable
works only for Kotlin data classes.
I have not added a converter for Protocol Buffers but might do so if this pull request gets accepted.
Closes gh-21188.
Comment From: aahlenst
@jhoeller Is there any chance that this might make it into 5.3 (happy to update/polish in that case) or would you prefer that I publish it as a separate artifact?
Comment From: jhoeller
@sdeleuze What's your take on this? If we move forward with it, 5.3 would be a fine timeframe from my perspective...
Comment From: sdeleuze
This would indeed be a very exciting feature, especially when you consider multiplatform scenarios like Spring Boot backend and KotlinJS frontend, but before giving an educated advice I need to talk with Kotlin team about the runtime API stability they plan to ensure for Kotlin 1.4, see https://github.com/Kotlin/kotlinx.serialization#current-project-status for more details. I will check with them and provide a feedback shortly.
Comment From: vanniktech
@aahlenst would you mind publishing this as a separate artifact in the meantime?
Comment From: sdeleuze
Ok so it seems we should be able to get stable support for the JSON part in Kotlin 1.4 timeframe. I think that's a good start since that enables multiplatform application with Spring backend, Kotlin/JS frontend and shared module.
@aahlenst Could you please update your PR to retain only the JSON support?
Comment From: aahlenst
@sdeleuze Will do. Do you have additional information regarding CBOR? We're using both JSON/CBOR with Multiplatform, primarily for mobile.
Comment From: sdeleuze
CBOR won't be stable at Kotlin 1.4 timeframe, it has been confirmed. But we will be happy to add it later. For the time being, I will make sure you can easily add it on your own.
Comment From: aahlenst
@sdeleuze Ready for review. I rebased everything and dropped the CBOR support. Adding CBOR again is painless, there are no dependencies on other classes.
Comment From: aahlenst
@sdeleuze Updated to Kotlin 1.4 and kotlinx.serialization 1.0.0-RC. Reading and writing of generics is now included, too.
Comment From: sdeleuze
Merged and polished via cd6085a31009e830b63461b71ae69e39afeac27c, thanks for this useful contribution @aahlenst.
Comment From: sdeleuze
I plan to add kotlinx.support to WebFlux (and its Coroutines support) in SpringFramework 5.3 RC2, see https://github.com/spring-projects/spring-framework/issues/25771 related issue.
Comment From: vanniktech
@aahlenst how/when will this make its way into spring boot?
Comment From: aahlenst
@vanniktech I'm the wrong person to ask because I'm not involved with any Spring project or Pivotal. Usually, there's a Boot release shortly after the Framework release. So I assume that will have it.
Comment From: snicoll
@vanniktech the milestone was removed by accident. This was added in Spring Framework 5.3.0-RC1
that got released last week. Each Spring Boot release has a list of versions in the reference guide. Spring Boot 2.4.0-M3
has been released with this work.