Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protobuf3 why repeated map is not allowed?

I am using Protobuf3 and I need to create a list of map. I thought I can use repeated map<string, string> but seems like I cannot.

What should I use instead?

thanks

like image 375
AnthonyC Avatar asked Sep 20 '25 08:09

AnthonyC


1 Answers

Essentially, map<...> is identical to:

repeated TypedPair ...

with

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

So repeated map<...> would be repeated repeated TypedPair which doesn't make sense.

Instead, define a type that has a map, and use that:

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

Could this be implicit? Perhaps - but it isn't right now.

like image 187
Marc Gravell Avatar answered Sep 21 '25 20:09

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!