Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum field decoding skipping 0 value #966

Closed
jalandis opened this issue Nov 18, 2023 · 1 comment
Closed

Enum field decoding skipping 0 value #966

jalandis opened this issue Nov 18, 2023 · 1 comment

Comments

@jalandis
Copy link
Contributor

enum values with 0 are decoded incorrectly.

message AccountAccess {
    enum AccessStatus {
        INACTIVE = 0;
        PENDING = 1;
        ACTIVE = 2;
    }

    AccessStatus status = 1;
}
if (message.status !== 0) {
   obj.status = accountAccess_AccessStatusToJSON(message.status);
}

An inactive value is decoded as undefined instead of INACTIVE.

@stephenh
Copy link
Owner

It's part of the protobuf3 JSON spec that default values can/should be left out of the JSON:

https://protobuf.dev/programming-guides/proto3/#json

But there is also a emitDefaultValues=json-methods flag if you don't like that behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants