3 ms·
You need it when an empty string is a valid value in your domain. A better example is Int32Value. By default, protobuf will serialize int32 to 0 if it's not pr
by parthdesai 2y ago
You need it when an empty string is a valid value in your domain.
A better example is Int32Value. By default, protobuf will serialize int32 to 0 if it's not present.
- anytime5704 2y agoI think the other commenter’s point is you can use 2 fields to distinguish between the first field being specified as empty vs absent (or whatever terms you prefer). E.g. - type.specified => “” - type.unspecified => empty The same technique can be used to disambiguate between 0 and empty.
- jahewson 2y agoWorth noting that it’s not quite equivalent due to allowing for a malformed message that includes foo = value and hasFoo = false, opening the door to varied client interpretation.
- adrianmsmith 2y agoBut why would you do that over using the built-in StringValue, that just works and does everything you need?