How to use reflection of Protobuf to modify a Map

21 views
Skip to first unread message

Yuhui ZHI

unread,
Apr 26, 2022, 11:05:55 AMApr 26
to Protocol Buffers
https://stackoverflow.com/questions/71995707/how-to-use-reflection-of-protobuf-to-modify-a-map

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

Can someone show me an example?

Adam Cozzette

unread,
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 protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/83e20e38-162a-4a20-98db-86b9fc547091n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages