implementation "io.ktor:ktor-serialization:$ktor_version"
@Serializable
data class User(val name: String, val age: Int)
post("/users") {
val user = call.receive()
// do something with user
}
如果你在调用call.receive
时仍然收到'序列化器未找到”的错误信息,请尝试在你的应用级别Gradle文件中添加以下Kotlinx序列化器插件:
plugins {
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.31"
}
然后重新构建你的项目,并再次尝试。