Hello everyone. Anyone could help me with a serialization error. I’ve set up an Exposed user in ktor 2:
object 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-exposed