does kotlin serialziation uses `Serializable` of ...
# serialization
r
does kotlin serialziation uses
Serializable
of java ? why I am asking this question, actually we need to store the some serialized data in local/Room DB With Java's Serializable, problem is if we make any changes to the class implementing Serializable,. Its
serialVersionUID
gets changed, which causes the problem in deserializing
c
No, kotlinx.serialization is for converting Kotlin objects into standard structured representations, like JSON or Protobuf. Java's
Serializable
is an internal format that is only useful within Java, and kotlinx.serialization has no interop or compatibility with it. Note that you can have a class be "serializable" with both Kotlinx.serialization, and also by the Java interface.
You really shouldn't be using Java
Serializable
for any reason other than marshalling data around your application. Because of its
serialVersionUID
and the fact that the serialized representation is so closely linked with the Class binary, it's not really meant to persist serialized state over time. In contrast, the standard formats like JSON are very-much designed to be parsed at a later date, with changes to the class/schema that originally produced it, or even to pass into other programming languages.
r
Ok cool, just wanted to confirm this
For
SerialVersionUID
I just got to know this Today
I was not aware of this thing