Is there a more elegant way to solve `ImplicitRefl...
# serialization
m
Is there a more elegant way to solve
ImplicitReflectionSerializer
? I want to create generic method to send data classes through Websocket. At the moment I have this:
Copy code
suspend fun <T> send(item: T, serializer: KSerializer<T>) {
    // TODO
}
but it is a bit awkward to always pass the serializer. Since I'm always sending data classes which do not support extension, runtime type is not important to me, I would be fine with just detecting the compile-time type.
s
reified
will give you KClass only, and to obtain KSerializer from KClass you'll need some reflection. For non-generic data classes it will work OK on JVM and JS, but on Native it is not available completely