How to serialize a library class to Protobuf with kotlinx.serialization? Since it's non-editable, I can't add @SerialId
annotations to its properties as instructed in runtime_usage.md#protobuf. If I write my own external serializer as in custom_serializers.md, it doesn't tell me how to specify the SerialId
s for Protobuf serialization.
For example, I am trying to serialize a java.math.BigDecimal
, storing its unscaledValue
as bytes
and its scale
as sint32
. It's easy to do it with the original Protobuf Java library, but I am wondering how to do it with kotlinx.serialization.