Reputation: 1293
We are using protobufs to model our networking software. There are many instances, like priorities, where 0 is a valid value. But, when we transport, the fields with 0 values are suppressed. Is there a way to change this behavior? That is, differentiate a filed with a valid value of 0, from a field which has not been set, which can be suppressed?
Our client is gRPC-Java and server is gRPC-Python.
Thank you for your time.
Upvotes: 1
Views: 390
Reputation: 22886
You can use Protobuf version 2, which can distinguish whether the field has been set. However, gRPC recommend to use Protobuf version 3.
An alternative is to set the field to an invalid value, e.g. -1
, if the field is NOT set.
Upvotes: 2