y
02/29/2024, 10:09 AMval expensiveProperty: Foo? by lazy { ... }
. I'd like to have it skipped by kotlinx
serialization and deserialization. is this possible?Johan
02/29/2024, 10:12 AMJohan
02/29/2024, 10:14 AMy
02/29/2024, 10:26 AMProperty does not have backing field which makes it non-serializable and therefore @Transient is redundant
but (and I could be wrong here!) I do observe this new lazy initializer getting called by serializationy
02/29/2024, 10:28 AMJohan
02/29/2024, 10:32 AM@Serializable
class Bar {
@delegate:Transient
val expensiveProperty: Foo by lazy { Foo() }
}
data class Foo(val value : String = "")
fun main() {
val bar = Json.decodeFromString<Bar>("""{}""")
val barJson = Json.encodeToString(bar)
println(barJson)
println(bar.expensiveProperty.value)
}
asdf asdf
02/29/2024, 3:11 PMy
02/29/2024, 3:12 PM