I have an object that is something like this:
{
"colorRestrictions": {
"availableColors":[ ... ],
"excludedColors": [ ... ]
}
}
How do I translate this into a proto file considering that colorRestriction is an object that can have either of the arrays?
The property oneof doesn't allow for repeated within the declaration.
I guess it's something common but I couldn't find a straight answer, any suggestions? Thanks
Fields are all optional in Protobuf 3. So just define ordinary fields.
oneofis for mutually-exclusive fields. It doesn't require that a field is present; aoneofcan be unset.Even in Protobuf 2
repeatedfields couldn't be marked as required.repeatedfields don't have normal field presence because "empty list" is encoded identically to "unset list." When you need presence information in a repeated field (e.g., to include it in aoneofor distinguish "empty list" from "unset list") you can wrap it in a message.