You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that I make any request that tries to decode something to a List<T>, where T is not serializable, Ktor-client will generate an error like this:
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.
at kotlinx.serialization.internal.Platform_commonKt.serializerNotRegistered(Platform.common.kt:90)
at kotlinx.serialization.SerializersKt__SerializersKt.serializer(Serializers.kt:299)
at kotlinx.serialization.SerializersKt.serializer(Unknown Source)
at io.ktor.serialization.kotlinx.SerializerLookupKt.serializerForTypeInfo(SerializerLookup.kt:32)
at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:66)
at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Emitters.kt:51)
Adding @Serializable to T fixed this in my case.
It's very frustrating and throws the user in the wrong direction. It seems to apply to all boxed types. For instance
data classFoo(valbar:Int)
@Serializable
data classBox<outT>(valvalue:T)
funmain() {
client.get("").body<Box<Foo>>()
}
Will generate a similar error statingkotlinx.serialization.SerializationException: Serializer for class 'Box' is not found.
Once again, making Foo serializable would fix this
Given that I make any request that tries to decode something to a
List<T>
, whereT
is not serializable, Ktor-client will generate an error like this:Adding
@Serializable
toT
fixed this in my case.It's very frustrating and throws the user in the wrong direction. It seems to apply to all boxed types. For instance
Will generate a similar error stating
kotlinx.serialization.SerializationException: Serializer for class 'Box' is not found.
Once again, making Foo serializable would fix this
Ktor version: 3.1.0
KxS version: 1.8.0
Kotlin version: 2.1.0
The text was updated successfully, but these errors were encountered: