Does anyone know the reasoning behind Ktor (with K...
# ktor
s
Does anyone know the reasoning behind Ktor (with Kotlinx.Serialization JsonFeature) trying to use reflection to find the serializer generated when annotating something with
@Serialized
when it always generates a KSerializer every time? I am explicitly setting it with
setMapper(KClass, KSerializer)
right now, but am wondering if there is a way to have it detect it as the KSerializer will always be there (to my knowledge).
l
i was just working through trying to answer a very similar question and it seems like there’s a base assumption in the content negotiation feature that the serializer has to be located dynamically. if you look at
ContentConverter
it doesn’t have any type parameters so as i understand it there’s no way (if you want to use ktor’s builtin content negotiation) to resolve a serializer or deserializer statically
i wanted to use helios but it generates extension properties on the companions to your data classes which have to be resolved statically
again, this is just my understanding, if anyone knows otherwise please correct me 🙂