I have polymorphic serialization, which is customizable by users of my library. They can put a
String
,
KClass
-Type and a
KSerializer
into a set. On serialization my own
KSerializer
searches for a matching
KClass
in this set, uses the users
KSerializer
to serialize the content and puts a
type
field into the Json from the
String
in the set.
This works very good, as long as the user does not use generics. With generics, the search of a matching
KClass
does not include the generic type (->type erasure).
Therefore it would be cool to use something like the
descriptor
to find a serializer, which can be used to serialize a given (generic) object.