dany giguere
05/07/2022, 9:16 PMobject Users: IntIdTable() {
val username = varchar("username", 128)
val email = varchar("email", 128)
val password = varchar("password", 1024)
}
class User(id: EntityID<Int>, username: String, email: String, password: String): IntEntity(id) {
companion object : IntEntityClass<User>(Users)
var username by Users.username
var email by Users.email
var password by Users.password
}
my serialization plugin is :
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.plugins.*
import io.ktor.server.application.*
fun Application.configureSerialization() {
install(ContentNegotiation) {
json()
}
}
when I call http://0.0.0.0:8080/users, I get
500: kotlinx.serialization.SerializationException: Serializer for class 'User' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
If I try adding @Serializable above the class User, my ide says
This class does not have a constructor
Cannot access 'Serializable': it is internal in '<http://kotlin.io|kotlin.io>'
You can view my project on this branch: https://github.com/danygiguere/ktor-kotlin-example/tree/setting-up-exposedephemient
05/07/2022, 9:42 PMkotlinx.serialization.Serializable
dany giguere
05/07/2022, 9:47 PMephemient
05/07/2022, 9:49 PMkotlin.io.Serializable
when you write @Serializable
ephemient
05/07/2022, 9:50 PMdany giguere
05/07/2022, 9:52 PMImpossible to make this class serializable because its parent is not serializable and does not have exactly one constructor without parameters
ephemient
05/07/2022, 9:57 PMconstructor(val)
, https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/basic-serialization.md#constructor-properties-requirementdany giguere
05/07/2022, 10:11 PMAleksei Tirman [JB]
05/08/2022, 8:32 AMUser
class.dany giguere
05/08/2022, 3:28 PM