如何使用kotlinx.serialization将库类序列化为Protobuf?由于它是不可编辑的,因此无法按照runtime_usage.md#protobuf中的说明在其属性中添加@SerialId
注释。如果我像custom_serializers.md那样编写自己的外部序列化程序,它不会告诉我如何为Protobuf序列化指定SerialId
。
例如,我尝试序列化java.math.BigDecimal
,将其unscaledValue
存储为bytes
,将其scale
存储为sint32
。使用原始的Protobuf Java库很容易做到这一点,但我想知道如何使用kotlinx.serialization来做到这一点。