Assuming I have a .proto with structure like this:
syntax = "proto3";
message Foo {
...
}
message Bar {
...
}
message Msg {
string baz = 1;
oneof some_union {
Foo foo = 2;
Bar bar = 3;
}
}
What is the expected way to serialise a message of this kind ? The JSON Mapping section of the spec is not very clear.
I can see at least two ways to represent it, which is the right one ?
First way: have a single element at the "top level", ignore the others:
{
"baz" : 0,
"foo" : { ... }
}
Second way: have an "unmbrella" property with the name of the union, and give it a single field.
{
"baz" : 0,
"some_union": {
"foo" : { .... }
}
}
What should I expect ?
I write some test code, it shows the first is the right one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With