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

V2: Rename JSON serialization option emitDefaultValues #863

Merged
merged 4 commits into from
May 29, 2024

Conversation

timostamm
Copy link
Member

@timostamm timostamm commented May 29, 2024

The documentation for the suggested JSON options has been updated recently. The documentation originally only applied to proto3, where the name emitDefaultValues fits. With Editions, this name has become ambiguous: The option does not actually emit field default values (which would change data with a serialization roundtrip), it only emits empty maps and lists, and zero values for proto3 singular scalar fields (fields with implicit presence).

This PR renames the option to alwaysEmitImplicit, and updates the documentation accordingly:

/**
 * By default, fields with implicit presence are not serialized if they are
 * unset. For example, an empty list field or a proto3 int32 field with 0 is
 * not serialized. With this option enabled, such fields are included in the 
 * output.
 */
alwaysEmitImplicit: boolean;

Signed-off-by: Timo Stamm <ts@timostamm.de>
Signed-off-by: Timo Stamm <ts@timostamm.de>
docs/runtime_api.md Outdated Show resolved Hide resolved
packages/protobuf/src/to-json.ts Outdated Show resolved Hide resolved
timostamm and others added 2 commits May 29, 2024 19:00
Co-authored-by: Steve Ayers <sayers@buf.build>
Co-authored-by: Steve Ayers <sayers@buf.build>
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

Successfully merging this pull request may close these issues.

2 participants