Fix `null` handling in proto3 JSON deserializer (#763)

[proto3 JSON spec][1] says this about `null` values:

> 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 when
> parsed into a protocol buffer

proto3 spec does not talk about presence, but in an internal spec we
have this about proto3 JSON null values:

> When parsing, a “null” value is accepted for all field types. It will
> be treated as if the field has the default value (the field itself
> would not be set, but its getter will return the default value for
> proto3).

So we shouldn't be initializing the fields with `null` values. The
"interpreted as default value" part in the public spec is already
handled by the getters.

With this #760 is no longer an issue as we don't generate empty message
for the field value when we have a message-field.

We will still accept proto3 JSON message encodings with missing
`required` fields, but that's by design. We don't check for `required`
fields until `GeneratedMessage.check` is called.

Closes #760

[1]: https://developers.google.com/protocol-buffers/docs/proto3#json
2 files changed
tree: e07644d499bee6e7dc15a2a30ad57d3da6819245
  1. .github/
  2. api_benchmark/
  3. benchmarks/
  4. protobuf/
  5. protoc_plugin/
  6. tool/
  7. .gitignore
  8. AUTHORS
  9. LICENSE
  10. mono_repo.yaml
  11. README.md
README.md

CI status

Protobuf support for Dart

Protocol Buffers (protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.

This repository is home to packages related to protobuf for Dart.

PackageDescriptionPublished Version
protobufA support library for the generated codepub package
protoc_pluginA Dart back-end for the protoc compilerpub package
api_benchmarkBenchmarking for various API calls
query_benchmarkBenchmark for encoding and decoding of a “real-world” protobuf