Question

Hi guys I want to know if there is a way to send a list of object throw protocol buffer ? as I read this page it say that you can but you need to write code yourself. I actually could not understand what is needed for that so, if someone can help it will be good. Here is the tutorial

Was it helpful?

Solution

Assume you defined a object named Foo,

message Foo {
    ...
}

If you want to send a list of Foo, you can make it a repeated field in another message,

message FooList {
    repeated Foo foos = 1;
}

You can check the 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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top