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

房东的猫 提交于 2019-12-23 07:38:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!