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

Umesh Gupta

12/11/2023, 6:49 PM
Hello need a little help in IOS. Getting an error -
failed with exception: kotlinx.serialization.SerializationException: Serializer for class 'List' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
Trying to parse a List of object
httpClient.get(url).body<List<Response?>?>()
JSON Response
Copy code
[
{"name" : "string"},
{"name" : "string"},
{"name" : "string"},
{"name" : "string"}
]
a

Aleksei Tirman [JB]

12/12/2023, 7:55 AM
Can you tell me where the
List
is imported from?
u

Umesh Gupta

12/12/2023, 7:56 AM
kotlin.collections
a

Aleksei Tirman [JB]

12/12/2023, 7:57 AM
Are able to receive and parse a serializable object (not a list)? Can you try to reproduce the problem without Ktor (just with the kotlinx.serialization framework)?
u

Umesh Gupta

12/12/2023, 7:58 AM
yes, getting bodyAsText and then further Json.decodefromstring works fine
a

Aleksei Tirman [JB]

12/12/2023, 8:02 AM
Does it work to get a body without nullable types -
httpClient.get(url).body<List<Response>>()
?
u

Umesh Gupta

12/12/2023, 8:51 AM
no
a

Aleksei Tirman [JB]

12/12/2023, 8:53 AM
Are you able to receive an object of some other type other than
List
?
u

Umesh Gupta

12/15/2023, 9:07 PM
yes
wrapping under a object
a

Aleksei Tirman [JB]

12/19/2023, 7:06 AM
That's strange. Are you able to reproduce the same problem on Android?