Proto3 定义返回 C# Dictionary<string, List<Dictionary<int, int>>> 类型
在 proto3 中,可以使用 Map 和 repeated 关键字来定义返回 C# Dictionary<string, List<Dictionary<int, int>>> 类型。具体如下:
syntax = "proto3";
message MyResponse {
map<string, repeated map<int32, int32>> myMap = 1;
}
在以上代码中,使用了 Map 关键字来定义了一个键类型为 string,值类型为 repeated map<int32, int32> 的 map 类型。其中,repeated 表示值可以是多个,map<int32, int32> 表示值的格式为键值对,键类型为 int32,值类型也为 int32。这样,就可以表示一个 Dictionary<string, List<Dictionary<int, int>>> 类型的数据。
原文地址: https://www.cveoy.top/t/topic/nwFd 著作权归作者所有。请勿转载和采集!