Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在协议缓冲区中,有没有办法让消息包含嵌套消息的集合?例如,消息主管可能具有员工集合以及主管的姓名和部门。
是的。您使用repeated字段;
repeated
message Employee { ... } message Supervisor { repeated Employee employees = 1; }
然后,您可以将该employees字段作为列表访问。
employees