(五)ProtoBuf数组类型

在protobuf消息中定义数组类型,是通过在字段前面增加repeated关键词实现,标记当前字段是一个数组。

一、整数数组的例子:

message Msg {
  // 只要使用repeated标记类型定义,就表示数组类型。
  repeated int32 arrays = 1;
}

二、字符串数组

message Msg {
  repeated string names = 1;
}
posted @ 2022-05-08 19:57  比特边界  阅读(3873)  评论(0编辑  收藏  举报