encode Object Starts
Specifies whether objects, empty classes and empty collections will be serialized by encoding a marker at the position.
@Serializable
data class PrefTest(val u: Unit)
val pref = Preferences(sharedPreferences) { encodeObjectStarts = true }
pref.encode(PrefTest.serializer(), "test", PrefTest(Unit))
assertTrue(sharedPreferences.getBoolean("test.u", false))
Content copied to clipboard
true
by default