-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
Milestone
Description
The testing message is defined as follows:
syntax = "proto2";
message MessageWithEnum {
enum EnumType {
FOO = 0;
BAR = 1;
}
optional EnumType value = 1;
}We observe the following serialization with pbandk:
| Source message | current JSON serialization | expected JSON serialization |
|---|---|---|
MessageWithEnum() |
{"value":null} |
{} |
MessageWithEnum(value=FOO) |
{} |
{"value":"FOO"} |
MessageWithEnum(value=BAR) |
{"value":"BAR"} |
OK! |
The bug is reproduced in a unit test here:
#234
I know that proto2 doesn't really have a JSON spec defined, but other protobuf implementations (java, python, swift) would all behave as expected in this example.
In proto3, we observed the following serialization behavior:
| Source message | current JSON serialization | expected JSON serialization |
|---|---|---|
TestAllTypesProto3() |
{} |
OK! |
TestAllTypesProto3(optionalNestedEnum = FOO) |
{} |
{"value":"FOO"} |
TestAllTypesProto3(optionalNestedEnum = BAR) |
{"value":"BAR"} |
OK! |
- Do you agree that the current behavior is unexpected?
- Would you be open for us contributing a fix for it?
Thank you for your time :)