Support unknown json data and add internal set/clear field methods for generated accessors. (#918)

Add support for unknown fields to JSON (de-)serialized proto messages.
This allows data to be roundtripped from a server via this format
without dropping fields when the client doesn't contain metadata for
some fields.

Store the data as decoded but unparsed json and append it back to the
message when re-serializing a message.

Ignore unknown json data for equality/hashing to preserve existing
behavior for users. Taking this data into account would change the
result of existing `==` and `hashCode` calls.

By separating out `$_setField` and `$_clearField` this allows one to
differentiate reflective uses of `setField` and `clearField` (i.e. from
user code, usually with the result of `getTagNumber`) vs. internal uses
from the generated accessors.

Fixes #49.

---

cl/611522109
cl/612283849

---------

Co-authored-by: Nate Biggs <natebiggs@google.com>
Co-authored-by: Ömer Sinan Ağacan <omersa@google.com>
18 files changed
tree: 71224b461f73f610a24554ba9903d18253eb7518
  1. .github/
  2. api_benchmark/
  3. benchmarks/
  4. protobuf/
  5. protoc_plugin/
  6. tool/
  7. .gitignore
  8. analysis_options.yaml
  9. AUTHORS
  10. LICENSE
  11. mono_repo.yaml
  12. 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

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.