google protobuffer 如何定义 proto 文件中的列表列表? [英] google protobuffer how to define list of lists in proto file?
本文介绍了google protobuffer 如何定义 proto 文件中的列表列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含列表字段列表的类,如下所示:
I have a class with a list of lists field as below:
public class MyClass{
private List<List<String>>
}
如何在 proto 文件中定义它?
how to define it in a proto file?
推荐答案
- 您可以在名为 message 的 proto 文件中声明您自己的类型".
- 如果你想声明一个列表,你应该使用repeated关键字.
- You can declare your own "types" in proto files called message.
- If you'd like to declare a list you should use repeated keyword.
将这两者结合起来给我们:
Combining those two gives us:
message ListOfListsOfStrings {
repeated ListOfStrings listOfStrings=1;
}
message ListOfStrings {
repeated string strings=2;
}
然后你可以在你的原型中使用 ListOfListsOfStrings 消息是合适的.
You can then use ListOfListsOfStrings message in your proto were appropriate.
这篇关于google protobuffer 如何定义 proto 文件中的列表列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文