Hi! What im doing wrong to deserialize list of objects?
Copy code
install(ContentNegotiation) {
json()
}
val client = HttpClient(CIO)
routing {
get("/users") {
val users: List<User> = client.get("$host/api/v4/users?private_token=$token").body()
call.respond(users)
}
}
Copy code
@Serializable
data class User(
val id: String,
val username: String,
)
this code returns this error
io.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class kotlin.collections.List
g
Goetz Markgraf
04/17/2023, 9:47 AM
What is your dependency? I just had the same problem. You need to use
io.ktor:ktor-serialization-kotlinx-json-jvm
and not
org.jetbrains.kotlinx:kotlinx-serialization-json
q
qwert_ukg
04/17/2023, 10:17 AM
im using a first one, but guess i found a problem - its coze ContentNegotiation for client and for server named same? and u cant to install both, without alias for import