https://kotlinlang.org logo
#ktor
Title
# ktor
a

addamsson

06/13/2020, 7:14 PM
Hi there! Do any of you know how can I use
call.receiveParameters()
when I use the content negotiation module? I get
Copy code
kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class Parameters. For generic classes, such as lists, please provide serializer explicitly.
How do I provide a serializer for Parameters? Or a Map? I'm using the kotlinx.serialization serializer like this:
Copy code
import io.ktor.application.Application
import io.ktor.application.install
import io.ktor.features.ContentNegotiation
import io.ktor.serialization.json

fun Application.configureContentNegotiation() {
    install(ContentNegotiation) {
        json()
    }
}
I also checked the docs but I did not find any examples for this.
t

Takashi

06/14/2020, 2:09 AM
In my case, I did the following and it worked.
Copy code
install(ContentNegotiation) {
    json(
            json = Json(configuration = DefaultJsonConfiguration.copy(prettyPrint = true)),
            contentType = ContentType.Application.Json
    )
}
👍 1
a

addamsson

06/23/2020, 9:31 AM
This is great, thanks!
🎉 1
3 Views