protocol-buffers-3

Protobuf3: How to describe map of repeated string?

家住魔仙堡 提交于 2019-11-30 07:08:53
The Official documentation about map type says: map<key_type, value_type> map_field = N; ...where the key_type can be any integral or string type (so, any scalar type except for floating point types and bytes). The value_type can be any type . I want to define a map<string, repeated string> field, but it seems illegal on my libprotoc 3.0.0 , which complains Expected ">" . So I wonder if there is any way to put repeated string into map. A Possible workaround could be: message ListOfString { repeated string value = 1; } // Then define: map<string, ListOfString> mapToRepeatedString = 1; But

How to define an optional field in protobuf 3

痴心易碎 提交于 2019-11-28 16:35:05
问题 I need to specify a message with an optional field in protobuf (proto3 syntax). In terms of proto 2 syntax, the message I want to express is something like: message Foo { required int32 bar = 1; optional int32 baz = 2; } From my understanding "optional" concept has been removed from syntax proto 3 (along with required concept). Though it is not clear the alternative - using the default value to state that a field has not been specified from the sender, leaves an ambiguity if the default value