-
Notifications
You must be signed in to change notification settings - Fork 37
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
Refactor JSON support to make kotlinx-serialization an internal dependency of pbandk #61
Milestone
Comments
garyp
added a commit
that referenced
this issue
Aug 11, 2020
* Rewrote JSON support to better implement the proto3 JSON spec. This includes support for the `json_name` protobuf option. * Added `JsonConfig` class that can be used for configuring JSON marshalling/unmarshalling at runtime. Currently supported configuration includes `ignoreUnknownFieldsInInput`, `outputDefaultValues`, and `outputProtoFieldNames`, which match the options described at https://developers.google.com/protocol-buffers/docs/proto3#json_options. * Got rid of the need for projects using `pbandk` to use the `kotlinx-serialization` gradle plugin and add a dependency on the `kotlinx-serialization` library. The library is now an internal implementation detail of `pbandk`. * Moved all of the binary marshalling functionality and most of the binary unmarshalling functionality from the generated code to the runtime library. * Added `protoMarshal(OutputStream)`, `protoUnmarshal(InputStream)`, and `protoUnmarshal(ByteBuffer)` overloads on the JVM. * Fixed some bugs with handling of `packed` fields, marshalling of enums in Javascript, and base64 encoding/decoding in Javascript. Breaking API changes: * Changed `Message` so that it no longer needs to extend from itself. * Added `@PbandkInternal` and `@PublicForGeneratedCode` annotations on relevant portions of the public API that are only public for pbandk's internal use. * The below methods are now defined as extension methods rather than being part of the `Message` interface. Code that calls these methods will now need to import them first. * `Message.jsonMarshal()` * `Message.Companion.jsonUnmarshal(String)` * `Message.protoMarshal()` * `Message.Companion.protoUnmarshal(ByteArray)` * These two method overloads: * `Message.jsonMarshal(kotlinx.serialization.json.Json)` * `Message.Companion.jsonUnmarshal(kotlinx.serialization.json.Json, String)` have been replaced with: * `Message.jsonMarshal(pbandk.json.JsonConfig)` * `Message.Companion.jsonUnmarshal(String, pbandk.json.JsonConfig)` * These two method overloads: * `Message.protoMarshal(pbandk.Marshaller)` * `Message.Companion.protoUnmarshal(pbandk.Unmarshaller)` have been replaced with: * `Message.marshal(pbandk.MessageMarshaller)` * `Message.Companion.unmarshal(pbandk.MessageUnmarshaller)` * Replaced `Marshaller` and `Unmarshaller` interfaces with `MessageMarshaller` and `MessageUnmarshaller`, which are much simpler and function differently from the previous interfaces. * Removed `Sizer` and `Util` from the public API. * Removed `UnknownField` constructors and the `UnknownField.size()` method from the public API. * `MessageMap.entries` is now a `Set` instead of a `List`. Fixes #23, fixes #61. Portions of the proto3 JSON spec that still need to be implemented are tracked in #72.
garyp
added a commit
that referenced
this issue
Aug 12, 2020
* Rewrote JSON support to better implement the proto3 JSON spec. This includes support for the `json_name` protobuf option. * Added `JsonConfig` class that can be used for configuring JSON marshalling/unmarshalling at runtime. Currently supported configuration includes `ignoreUnknownFieldsInInput`, `outputDefaultValues`, and `outputProtoFieldNames`, which match the options described at https://developers.google.com/protocol-buffers/docs/proto3#json_options. * Got rid of the need for projects using `pbandk` to use the `kotlinx-serialization` gradle plugin and add a dependency on the `kotlinx-serialization` library. The library is now an internal implementation detail of `pbandk`. * Moved all of the binary marshalling functionality and most of the binary unmarshalling functionality from the generated code to the runtime library. * Added `protoMarshal(OutputStream)`, `protoUnmarshal(InputStream)`, and `protoUnmarshal(ByteBuffer)` overloads on the JVM. * Fixed some bugs with handling of `packed` fields, marshalling of enums in Javascript, and base64 encoding/decoding in Javascript. Breaking API changes: * Changed `Message` so that it no longer needs to extend from itself. * Added `@PbandkInternal` and `@PublicForGeneratedCode` annotations on relevant portions of the public API that are only public for pbandk's internal use. * The below methods are now defined as extension methods rather than being part of the `Message` interface. Code that calls these methods will now need to import them first. * `Message.jsonMarshal()` * `Message.Companion.jsonUnmarshal(String)` * `Message.protoMarshal()` * `Message.Companion.protoUnmarshal(ByteArray)` * These two method overloads: * `Message.jsonMarshal(kotlinx.serialization.json.Json)` * `Message.Companion.jsonUnmarshal(kotlinx.serialization.json.Json, String)` have been replaced with: * `Message.jsonMarshal(pbandk.json.JsonConfig)` * `Message.Companion.jsonUnmarshal(String, pbandk.json.JsonConfig)` * These two method overloads: * `Message.protoMarshal(pbandk.Marshaller)` * `Message.Companion.protoUnmarshal(pbandk.Unmarshaller)` have been replaced with: * `Message.marshal(pbandk.MessageMarshaller)` * `Message.Companion.unmarshal(pbandk.MessageUnmarshaller)` * Replaced `Marshaller` and `Unmarshaller` interfaces with `MessageMarshaller` and `MessageUnmarshaller`, which are much simpler and function differently from the previous interfaces. * Removed `Sizer` and `Util` from the public API. * Removed `UnknownField` constructors and the `UnknownField.size()` method from the public API. * `MessageMap.entries` is now a `Set` instead of a `List`. Fixes #23, fixes #61. Portions of the proto3 JSON spec that still need to be implemented are tracked in #72.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice to have with this refactor:
The text was updated successfully, but these errors were encountered: