How can I represent a 2-dimensional array in Protocol Buffers?

multidimensional-array, protocol-buffers

Solution

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;

Problem

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.

Original source

Related problems