We are planning to move our existing services to move grpc service. so need to convert the services to proto Defined Message Type. In the reponse, we have map with customize object as key.
eg response:
//java
Map<key_object, Project>
//proto
map<key_object_not_supported, Project> projects = 3;
In the official doc, they mentioned,
where the key_type can be any integral or string type (so, any scalar type except for floating point types and bytes). The value_type can be any type
Is it any alternative ways to achieve customise object key map in the proto3 ?
Support for map is a rather new extension. If your key does not match the constraints, you can use the old way instead:
Define a key-pair message and use that as a repeated field. So, in your example:
message KeyValuePair {
key_object_not_supported key = 1;
Project value = 2;
}
message MyMap {
repeated KeyValuePair entries = 1;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With