Reputation: 59
How to fill StringValue in protobuf (programming in python)
message event {
string id = 1;
google.protobuf.StringValue test = 2;
}
Upvotes: 1
Views: 5683
Reputation: 1
You can use StringValue constructor
from google.protobuf.wrappers_pb2 import StringValue
event(
test=StringValue(value="test")
)
Upvotes: 0
Reputation: 11008
event.test.value = 'test'
Also works. It is more straightforward and doesn't require importing StringValue
class.
Upvotes: 5
Reputation: 59
After fighting for a while found the answer
event.test.CopyFrom(wrappers.StringValue(value='test'))
Upvotes: 4