Reputation: 476
I am playing around with the new features of protobuf 3 and was wondering if there is a way to put primitive types like int32 or string into an google.protobuf.Any.
I know I can just set the type_url and value directly as those are strings, but that will break any code that checks the value with someAny.Is<SomeType>()
.
Also writing to JSON with BinaryToJsonString will not work in this case.
Or is there any other elegant way to union primitves and Messages? (oneofs are not what I'm searching for ;)
Upvotes: 4
Views: 1614
Reputation: 476
Apparently there is no way to do this directly. We now use the wrapper messages from google.protobuf.wrappers.proto and pack those into the Any.
Upvotes: 5