-
Notifications
You must be signed in to change notification settings - Fork 382
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
Print/parse JSON #142
Comments
isn't formatting data as json better handled with something like |
@CoDEmanX Actually, binary protobuf is quite portable. It is designed for that, and encoding is well specified. Protobuf encoding as JSON is needed to be implemented one day. It is also well specified, but it is not a priority, because encoding as JSON is not a primary goal of protobuf. |
I'm not concerned about portability actually, I'm looking for a way to make protobuf human-readable. Debug printing is human-readable, except that it lacks line breaks (maybe just on Windows?), and binary data is oddly encoded, but I need it encoded as true binary data. Because I have no Rust knowledge, JSON would be the most straightforward solution, because it would be human-readable and even a browser could decode the binary bits. I guess I could write protobuf messages to file and read them back in with e.g. Node.js and try to convert them to JSON there... As for the future of rust-protobuf: it would be great if it could parse protobuf to native Rust data structures. From there to JSON would probably be a lot easier, maybe there's even a crate for this already... |
I'm very new to Rust so I can't necessarily help with this for a while, but having a canonical JSON format that can be both serialized and deserialized is a very useful feature because it lets you use the Protobuf toolchain and generated code with a robust JSON wire format or have human editable config files that are strongly typed and easily read via protobuf (which is one of my use cases). |
Done except for the special handling of
|
@stepancheg Can you publish a version of this crate that exports the |
@Ubehebe it is not easy: master version of protobuf is not compatible with current stable version (lots of things changed in codegen, reflection and APIs). Porting it to stable version is possible, but hard. It is relatively easy to backport JSON printing only (stable version does not implement reflection for mutability reflection), but I'm not sure there's a demand for printing only. |
Hi, just a question: Is there a reason why this functionality (which was backported for v2.9 according to https://docs.rs/protobuf/2.9.0/protobuf/json/index.html) was removed from the v2.10 branch? Thank you! |
@aaronshim it broke backwards compatibility with generated code, unfortunately. I wanted to implement it backwards-compatible way, but that's a significant amount of work. |
Version 2.9.0 is yanked BTW |
Spec: https://developers.google.com/protocol-buffers/docs/proto3#json
Any
Timestamp
The text was updated successfully, but these errors were encountered: