generate js proto3 canonical json#1
Open
amarkowitz wants to merge 1 commit into
Open
Conversation
* this is to enhance the integration of javascript in the protobuf eco-system via enabling the option to use proto3 compatible JSON as the wire format for message passing instead of only supporting binary. This is support is enabled via the new toJSONObject() method on messages
ddb8387 to
d980e7b
Compare
Owner
Author
|
Looks like someone may be trying to support JSON as a wireformat and also provide some other things given this recent checkin from a couple of weeks ago: https://github.com/protocolbuffers/protobuf/tree/master/js/experimental |
|
I like this better :-) |
Owner
Author
|
😃 - me too... It's like they've been in the code base and know the eco system. or something ;) |
|
But I was talking about your code :-P |
Owner
Author
|
Oh.. Haha! Thanks! I def think that a better approach would be to generate the descriptors for runtime and then use that information to generate JSON. A lot more flexibility there. I'll keep this branch around for posterity and to pick things from tho ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This approach takes direction from the existing binary serialization generation within the js compiler. I am not too familiar with the protobuf ecosystem so it's possible that there are other approaches that are more inline with the trajectory of that project, such as generating Descriptors for the proto definitions and moving all of the serialization logic to the runtime (for example, a JsonFormatter that can read the field definitions from the Descriptors). 🤷♂
Also of note, javascript only supports accurate integers up to 2^53-1, so 64 bit is troublesome. See long.js or other implementations for being able to deal with large numbers.