-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Serializing protobufs to json #351
Comments
Have you tried Message#encodeJSON? |
The method doesn't seem to use canonical proto3 JSON encoding as specfied in here: https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json |
Did you sort out if Google's support for json, makes bufferjs redundant ? I suspect that bufferjs allows marshalling between json and PB client side, and grpc allows marshalling between the two server side at the facade. I would like to know what the answer to this is from an architectural perspective. |
+1. My use case is to encode to and decode from the canonical formatted JSON data, since React Native's js-native bright is text-based. |
Closing this for now. Feel free to send a pull request if this is still a requirement. |
@dcodeIO Sorry, it's not clear to me - is the issue closed because any changes discussed here are no longer relevant (due to rewrite) or because protobuf.js 6.x now supports the functionality? |
Not quite, but the default toJSON implementation of message instances should be close. someMessage.toJSON();
// or
SomeMessage.toObject(someMessage, util.toJSONOptions); Not yet supported:
Feel free to reopen! |
…lity of NaN and Infinity + additional documentation of util.toJSONOptions, see #351
Related: #677 |
with proto3, protocol buffers now have a standard json format, is there a way to leverage this with this library?
my use case is caching protocol buffers in local storage. currently i've been base64 encoding the messages before storing them. this becomes more complex with the
Map
type.The text was updated successfully, but these errors were encountered: