2D array of strings in proto3

25 views
Skip to first unread message

Haseeb Bhatti

unread,
Jan 2, 2023, 7:31:01 AMJan 2
to Protocol Buffers
Hi everyone!
I am new to proto3 and loopback4. I want to declare a 2D array of strings in proto3 interface message service:  I want the result to be like this: [[""],  [""] , [""] ], Kindly help me to solve this, i have searched everywhere but didn't find support of 2D array in proto3.
Thanks

Jorg Brown

unread,
Jan 16, 2023, 5:24:32 PMJan 16
to Protocol Buffers
Proto has no support for arrays with more than one dimension.  Therefore you'll need to create an array of arrays.  Or in proto terms, a repeated field of a proto message, where that message has a repeated field of strings.

Example:

message RowOfStrings {
  repeated string row = 1;
}

message ArrayOfStrings {
  repeated RowOfStrings col = 1;
}

-- Jorg

Reply all
Reply to author
Forward
0 new messages