@Serializable
data class Teaser(
@SerialName("text")
val textObj: Text
) {
constructor(text: String) : this(Text(text))
@Transient // not sure if this is needed
val text: String
get() = textObj.content
@Serializable
data class Text(val content: String)
}
z
zt
02/09/2023, 2:51 AM
isn't this for just serializing? I only need deserializing
m
Mitchell Syer
02/09/2023, 2:52 AM
The
Serializable
annotation is for both serializing and deserializing
Mitchell Syer
02/09/2023, 2:54 AM
If you don't need serializing you can remove the secondary constructor from the code I posted