Pedro Alberto
01/31/2023, 12:28 AMio.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteBufferChannel (Kotlin reflection is not available) -> class com..ApiResponse (Kotlin reflection is not available)
am trying to parse an array of ints but seems impossible
{
"numbers": [
4, 150,...
]
}
obj am using is
@Serializable
class ApiResponse(val numbers: Array<Int>)
calling it like this
val response: ApiResponse = httpClient.get(url).body()
Aleksei Tirman [JB]
01/31/2023, 8:56 AMPedro Alberto
01/31/2023, 10:46 AMPedro Alberto
01/31/2023, 11:29 AMAleksei Tirman [JB]
01/31/2023, 3:59 PMval client = HttpClient(Darwin) {
install(ContentNegotiation) {
json()
}
}
val r = client.get("<http://localhost:4444/>").body<ApiResponse>()
println(r.numbers.first())
Server:
embeddedServer(Netty, port = 4444) {
routing {
get("/") {
call.respondText(contentType = ContentType.Application.Json) { """
{
"numbers": [
4, 150, 6, 8
]
}
""".trimIndent() }
}
}
}.start(wait = true)
Pedro Alberto
02/01/2023, 9:23 AMAleksei Tirman [JB]
02/07/2023, 8:01 PM