How can I represent a 2-dimensional array in Proto

2019-06-15 21:13发布

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条回答
孤傲高冷的网名
2楼-- · 2019-06-15 21:22

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;
查看更多
登录 后发表回答