:wave: I’m testing out kotlinx.serialization’s pro...
# serialization
e
👋 I’m testing out kotlinx.serialization’s protobuf support, and discovered that “null is not supported”. Here’s my data class:
Copy code
@Serializable
data class Foo(@SerialId(1) @Optional val id: Int? = null)
and a failing test:
Copy code
@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