I wanna ask that how to encode (serialization) Map Fields.
According to the google guide, "JavaScript Generated Code" contains the following function for Map Fields. The decoding function (getFooMap()
) is generated. But I couldn't find the encoding functions or guide for map type anywhere. (I thought there would be a function like setXXXMap()
, but I couldn't find it.)
How should I encode Map Fields?
https://developers.google.com/protocol-buffers/docs/reference/javascript-generated#map
Map Fields
For this message with a map field:
message Bar {}
message Baz {
map<string, Bar> foo = 1;
}
the compiler generates the following instance method:
getFooMap()
: Returns the Map containing foo's key-value pairs. You can then use Map methods to interact with the map.