Kotlinx.serialization equivalent to GSON’s RunTimeTypeAdapterFactory

I really need help serializing with Kotlinx. I have the corresponding concept for serialization in GSON and fail with the migration.

My original RunTimeTypeAdapterFactory is a factory of type factories that dynamically cast classes to a list property of the child depending on its type.

So far I haven’t been able to find a good migration or useful article that explains this part. I read about the PolymorphicSerializer and ContextualSerializer in the official guide, but I couldn’t derive the concept I needed from them.

I really appreciate any help. Thanks in advance.

submitted by /u/Airtime69
[link] [comments]