How to use reflection of Protobuf to modify a Map

Skip to first unread message

Yuhui ZHI

Apr 26, 2022, 11:05:55 AMApr 26
to Protocol Buffers

I just don't know how to use reflection to set a google::protobuf::Map.

Can someone show me an example?

Adam Cozzette

Apr 26, 2022, 12:45:20 PMApr 26
to Yuhui ZHI, Protocol Buffers
For the purposes of reflection, maps are treated like a repeated field of messages, where each message has a key in field 1 and a value in field 2. The Descriptor type has map_key() and map_value() methods to make it easy to get ahold of the key and value field descriptors.

You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages