encodeObjectStarts

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))

true by default