Open
Description
It would be really useful if we could specify serializers for non-serializable properties at runtime, similarly to how we specify serializers for generic properties. An imaginatory API could look like this.
The code from a library:
interface Args
@Serializable
class ArgsHolder(@DynamicallySerializable val args: Args)
Then the library consumer's (client) code:
@Serializable
class ArgsA(val data: String) : Args
@Serializable
class ArgsB(val data: String) : Args
val argsSerializer : KSerializer<Args> = ... // Created dynamically at runtime
val serializer = ArgsHolder.serializer(ArgsSerializer)