KotlinSerializationJsonHttpMessageConverter doesn't work on MutableList
Affects: 6.1.12
Hi all,
I'm using spring-web in Kotlin as a REST client and I encountered some issues when trying to serialize a MutableList
I prepared a sample code to show the issue:
fun main() { val client = RestTemplate(listOf( KotlinSerializationJsonHttpMessageConverter() )) val data = mutableListOf<String>() data.add("1") data.add("2") val entity = HttpEntity(data, HttpHeaders().apply { contentType = MediaType.APPLICATION_JSON }) val response = client.exchange("https://httpbin.org/post", HttpMethod.POST, entity, String::class.java) logger.info(response.body) }
But when I run this code, I get this error:
No HttpMessageConverter for java.util.ArrayList and content type "application/json"
I assumed KotlinSerializationJsonHttpMessageConverter Would be able to convert this to ["1", "2"], but it doesn't seem to work