https://kotlinlang.org logo
b

Big Chungus

09/27/2019, 7:04 AM
Is there any way to serialize KClass with kotlinx.serialization?
s

Sebastian Sellmair [JB]

09/27/2019, 8:37 AM
This might be a dumb idea, but can’t you just send the fully qualified name of that class 🤔
b

Big Chungus

09/27/2019, 8:37 AM
That's what I'm trying now, the problem is then how do i deserialize that?
The class lies in common module
As in domain class i'm trying to serialize
s

spand

09/27/2019, 12:08 PM
I just want to post this from the kotinx.serialization KEEP: Usually, polymorphism usage in serialization is discouraged because of the security problems it entails. However, writing complex business logic is almost impossible without this main OOP feature. In this serialization framework, we get rid of the 'deserialize-anything' security problem that plagues naive approaches to polymorphism in serialization. All serializable implementations of some abstract class must be registered in advance. This also avoids reflection usage (such as Class.forName), which makes naive polymorphic serialization hard to implement on Kotlin/JS.
15 Views