Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collections in Protocol Buffers messages?

In protocol buffers is there a way to have a message with collection of nested messages? For example a message Supervisor might have a collection of Employees along with the name and department of the supervisor.

like image 491
insipid Avatar asked Jan 22 '10 19:01

insipid


1 Answers

Yes. You use repeated fields;

message Employee
{
    ...
}

message Supervisor
{
    repeated Employee employees = 1;
}

You can then access the employees field as a list.

like image 100
JesperE Avatar answered Sep 19 '22 17:09

JesperE