Guilherme Delgado
04/21/2021, 8:20 PM//client
HttpClient(Apache) {
install(JsonFeature) { serializer = KotlinxSerializer(Json { ignoreUnknownKeys = true }) }
}
//server
install(ContentNegotiation) {
kotlinx.serialization.json.Json { ignoreUnknownKeys = true }
// gson { setPrettyPrinting() }
}
and this is a sample request:
val response = client.get<List<Event>>("<http://localhost:8080>${application.locationToUrl(EventsApi())}") {
body = ...
contentType(ContentType.Application.Json)
}
and this is the output:
invalid: 415 Unsupported Media Type. Text: ""
But if I uncomment gson { setPrettyPrinting() }
it works…
Shouldn’t kotlinx.serialization.json.Json
be enough? 🤔Rustam Siniukov
04/21/2021, 8:57 PMGuilherme Delgado
04/22/2021, 3:27 PM@SerialName
I don’t if its related, but the SS can parse it (when it communicates for instance with Google Api or any other service), but the web app can’t (it shows null) 🤔install(ContentNegotiation) {
json(kotlinx.serialization.json.Json {
ignoreUnknownKeys = true
prettyPrint = true
})
}
instead of:
install(ContentNegotiation) {
kotlinx.serialization.json.Json {ignoreUnknownKeys = true }
}