protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Recommend default JSON behavior not to output explicit `null` values

Open antongrbin opened this issue 3 years ago • 0 comments

Motivation

As of today I don't intend to merge this to master. I am using this only to test the current behavior of various implementations.

Related discussion with a 3rd party library pbandk here: https://github.com/streem/pbandk/issues/235.

Note that all tests are RECOMMEND since emitting a null value should hurt any compliant parsers due to the following line from JSON spec:

If a value is missing in the JSON-encoded data or if its value is null, it will be interpreted as the appropriate [default value](https://developers.google.com/protocol-buffers/docs/proto3#default) when parsed into a protocol buffer.

Tested

The following tests pass locally for c++, java and python implementations.

bazel test //java/core:conformance_test //java/lite:conformance_test //python:conformance_test //src:conformance_test

antongrbin avatar Oct 25 '22 10:10 antongrbin