On Fri, Jul 20, 2018 at 10:22 PM jiandai via Protocol Buffers <
[email protected]> wrote:
> Hi there,
>
> I am creating a protobuf message to match with a JSON data in legacy
> application. The problem is that legacy JSON has mulitple enum data, and
> some of them have the same enum name, like "NONE".
>
> I know protobuf requires enum name uniqueness on the scope of package and
> protobuf convert to JSON based on enum name. I was wondering, in my case
> here, is there any way that I can,
>
> 1. workaround protobuf enum sibling constriction and build the enums with
> the same name in a same package? Or,
> 2. request protobuf converter to convert enum into different name, and
> vice versa?
>
You can put enums with the same name in the same package but they have to
be contained in separate message types. I.e.:
message Foo {
enum MyEnum {
NONE = 0;
}
}
message Bar {
enum MyEnum {
NONE = 0;
}
}
Because we only use the short name in JSON, the above 2 enums will end up
with the same JSON value "NONE".
>
> Many thanks in advance for the nice help.
>
> Jian
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.