Hamza GATTAL
10/27/2020, 3:40 PMcoroutinedispatcher
10/27/2020, 3:49 PM@Parcelize
data class MyClass(
val id: Int,
val name: String
) : Parcelable
Hamza GATTAL
10/27/2020, 4:29 PMgildor
10/27/2020, 11:30 PMcoroutinedispatcher
10/28/2020, 8:23 AM@Serializable
as wellgildor
10/28/2020, 8:47 AMgildor
10/28/2020, 8:49 AM<http://java.io|java.io>.Serializable
is better than Parcelable on Android or usage of Kotlinx Serialization
My point is that question was not “what is best way to serialize class in Kotlin”, it was about how to convert Java class to Kotlin. And answer is that just implement Serializable interface, same as in java, and yes, use Kotlin properties and constructor initialiser as you suggested
Parcelable or kotlinx,serialization is much wider topic, you cannot use any of them and keep old code working, it requires migration of existing code