How to set multiple keys for protobuf Maps

21 views
Skip to first unread message

Michael Nguyen

unread,
Jun 3, 2019, 7:44:48 PM6/3/19
to Protocol Buffers
I am trying to create a dictionary as part of my message and I would like to have multiple keys for the dictionary. Here's what my message currently looks like:

message User {

string name = 1;
 
string manager = 2;

string id = 3;

map<string, string> metadata = 4;

}


In the metadata field I would like to save the following data:

metadata_info = {
"sync_direction": "OUTBOUND",
"status": "UNCONFIRMED",
}


What is the best way to save my metadata_info to the metadata field in my User message? Should I just use setattr(message, "metadata", metadata_info) to accomplish this? I am currently using Proto3 and Python3 at the moment.

Reply all
Reply to author
Forward
0 new messages