问题
How can I represent a 2-dimensional array in Protocol Buffers?
I need to store int
and double
2d arrays as a field on a PB message, for example:
int[][] multi = new int[5][10];
I'm using C++, Java and C#.
Thanks in advance.
回答1:
There is no direct support in the protocol for this. Your best bet is to have a repeated set of objects that have an array each - i.e.
message Foo {
repeated int items = 1;
}
...
repeated Foo foos = 1;
来源:https://stackoverflow.com/questions/20968626/how-can-i-represent-a-2-dimensional-array-in-protocol-buffers