insipid
insipid

Reputation: 3308

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.

Upvotes: 5

Views: 3821

Answers (1)

JesperE
JesperE

Reputation: 64454

Yes. You use repeated fields;

message Employee
{
    ...
}

message Supervisor
{
    repeated Employee employees = 1;
}

You can then access the employees field as a list.

Upvotes: 8

Related Questions