https://kotlinlang.org logo
#ktor
Title
# ktor
t

tylerwilson

12/27/2021, 2:47 PM
Question: I am testing moving up to Ktor 2.0 beta1 from Ktor 1.6.7. Previously I had code like so:
Copy code
val serializer = CommonResponse.serializer(Special.serializer())
val response = parser.decodeFromString(serializer)
Is there something similar I can do for HttpResponse.body? It takes a TypeInfo, but I am unsure whether I can get one from the generic serializers. Thank you.
To answer my own question, turns out pretty simple:
Copy code
val response: CommonResponse<Special> = result.body()
performs all the magic needed. Very nice.