Skip to content

Conversation

@antongrbin
Copy link

@antongrbin antongrbin commented Oct 25, 2022

Motivation

I don't intend to merge this.

Test behavior of includingDefaultValueFields when we have an unset nested message field.

Observations

  • In C++ "include default fields" is actually called always_print_primitive_fields which specifies that this affects only primitive fields.

  • In Java, there is a unit test that shows that even if includingDefaultValueFields we will not emit a null for unset nested message

  • In Python, we see in this PR that including_default_value_fields doesn't affect nested messages. Tested with bazel test //python:json_format_test

garyp pushed a commit to streem/pbandk that referenced this pull request Oct 25, 2022
…#238)

# Motivation

Fixes #235 

# Changes

* Change the behavior for JSON serialization for fields with explicit presence.
* If unset -> don't emit on the wire.
* If set -> emit on the wire, even if the value is default (regardless of the `jsonConfig.outputDefaultValues`)

This is consistent with the following:
https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md#semantic-differences

This PR also changes behavior of `outputDefaultValues` for unset nested message fields. Before we were outputting `null` and now we don't output any value. This is consistent with c++, python and java, as explained here: noom/protobuf#5

# Tested

Run all unit tests in `runtime`
garyp pushed a commit to streem/pbandk that referenced this pull request Mar 7, 2023
…#238)

Fixes #235

* Change the behavior for JSON serialization for fields with explicit presence.
* If unset -> don't emit on the wire.
* If set -> emit on the wire, even if the value is default (regardless of the `jsonConfig.outputDefaultValues`)

This is consistent with the following:
https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md#semantic-differences

This PR also changes behavior of `outputDefaultValues` for unset nested message fields. Before we were outputting `null` and now we don't output any value. This is consistent with c++, python and java, as explained here: noom/protobuf#5

Run all unit tests in `runtime`
antongrbin pushed a commit that referenced this pull request Jan 10, 2024
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