大家好我想知道是否有办法发送对象抛出协议缓冲区列表?当我读到这个页面时,它说你可以,但你需要自己编写代码。我实际上无法理解为什么需要这样做,如果有人可以帮助它会很好。 这是tutorial
答案 0 :(得分:1)
假设您定义了一个名为Foo的对象
message Foo {
...
}
如果要发送Foo列表,可以在另一条消息中将其作为重复字段,
message FooList {
repeated Foo foos = 1;
}
您可以查看language guide,
You specify that message fields are one of the following:
required: a well-formed message must have exactly one of this field.
optional: a well-formed message can have zero or one of this field (but not more than one).
repeated: this field can be repeated any number of times (including zero) in a well-formed message. The order of the repeated values will be preserved.