protocolbuffers / protocolbuffers/protobuf

enum values should have `json_name` pseudo-option just like fields

Open
#4,328 15 comments 75 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

enhancement json keep open
Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

Description

Fields can be renamed, even when using JSON format, by setting json_name and ensuring that it never changes. This allows the field's name to change without impacting how it is serialized to/de-serialized from JSON.

Since enum values are also identified by name in the JSON format, they should have an analogous feature: a json_name pseudo-option, allowing the enum value's actual name to change while its JSON encoding remains the same.

I call the existing field json_name a "pseudo-option" because, though it uses the option syntax in proto source, it does not end up in the google.descriptor.FieldOptions message. Instead, it is promoted to a field of google.descriptor.FieldDescriptorProto. For symmetry, I would expect the enum value option to behave similarly, resulting in a new json_name field on google.descriptor.EnumValueDescriptorProto.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.