I want to create a protobuf which returns a map containing custom keys. When I try to make one, I get an error: Key in map fields cannot be float/double, bytes or message types
. I want to know if there is a workaround for it.
I am trying to create a map of following type (as an illustration):
message Name {
string first_name = 1;
string last_name = 2;
}
message GetNameResp {
map<Name, string> name_info = 1;
}
So, can the Name
here be a possible key to the map? The only solution I could find was to serialize the map and then return as repeated
values.
Thanks!