egorand
03/04/2019, 5:55 PM@Serializable
data class Foo(@SerialId(1) @Optional val id: Int? = null)
and a failing test:
@Test fun nulls() {
val serialized = ProtoBuf.dumps(Foo.serializer(), Foo())
assertEquals(Foo(), ProtoBuf.loads(Foo.serializer(), serialized))
}
I found this issue: https://github.com/Kotlin/kotlinx.serialization/issues/71, and it looks like the concept of optionality has been added in 0.10.0 and Kotlin 1.3.20 (I’m on 0.10.0 and Kotlin 1.3.21), but I’m struggling to figure out how to configure ProtoBuf to allow serializing nulls