問題描述
.Net 字典類型在 protobuff (.Net dictionary type in protobuff)
你能幫我在 protobuff 中識別這種類型嗎?錯誤缺少“>”
class SomeRequest
{
Dictionary<long,List<string>> values;
}
message SomeRequest
{
map<int64,repeated string> values = 1;
}
參考解法
方法 1:
Basically, you can't do that. The closest you can get is a map to something that has a repeated element, so:
message SomeRequest
{
map<int64,Thing> values = 1;
}
message Thing {
repeated string items = 1;
}
Or in c# terms:
class SomeRequest
{
Dictionary<long,Thing> values;
}
class Thing
{
List<string> items;
}
(by phantasm、Marc Gravell)