Skip to content

generate js proto3 canonical json#1

Open
amarkowitz wants to merge 1 commit into
masterfrom
adm/js-proto3-json
Open

generate js proto3 canonical json#1
amarkowitz wants to merge 1 commit into
masterfrom
adm/js-proto3-json

Conversation

@amarkowitz

@amarkowitz amarkowitz commented Feb 14, 2020

Copy link
Copy Markdown
Owner

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.

* 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
@amarkowitz

Copy link
Copy Markdown
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

@amarkowitz amarkowitz closed this Feb 24, 2020
@amarkowitz amarkowitz deleted the adm/js-proto3-json branch February 24, 2020 18:39

@kppk kppk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool!

@kppk

kppk commented Feb 24, 2020

Copy link
Copy Markdown

I like this better :-)

@amarkowitz

Copy link
Copy Markdown
Owner Author

😃 - me too... It's like they've been in the code base and know the eco system. or something ;)

@kppk

kppk commented Feb 26, 2020

Copy link
Copy Markdown

But I was talking about your code :-P

@amarkowitz

Copy link
Copy Markdown
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 ;)

@amarkowitz amarkowitz restored the adm/js-proto3-json branch February 27, 2020 18:15
@amarkowitz amarkowitz reopened this Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants