Protobuf3为什么不允许重复地图?

时间:2018-01-11 06:55:37

标签: java protocol-buffers

我正在使用Protobuf3,我需要创建一个地图列表。 我以为我可以使用repeated map<string, string>但似乎我不能。

我应该使用什么?

感谢

1 个答案:

答案 0 :(得分:3)

基本上,map<...>与:

相同
repeated TypedPair ...

message TypedPair {
    KeyType key = 1;
    ValueType value = 2;
}

所以repeated map<...>将是repeated repeated TypedPair,这是没有意义的。

相反,定义具有地图的类型,并使用:

message HazMap {
    map<...> map = 1;
}
...
repeated HazMap maps = 1;

这可能是隐含的吗?也许 - 但现在不是。