4 ms·
Can I ask which library you are using? I found a few [1] but none seem super robust. Also, how do you deal with the bytes type? [1] https://code.google.com/p/
by teh 11y ago
Can I ask which library you are using? I found a few [1] but none seem super robust.
Also, how do you deal with the bytes type?
[1]
https://code.google.com/p/protobuf-json/ https://code.google.com/p/protobuf-json/
https://github.com/benhodgson/protobuf-to-dict https://github.com/benhodgson/protobuf-to-dict
- philsnow 11y agoJust a guess here: I would have an agreed-upon key name suffix like "__b64_enc" or something. Serializers take a field "foo" of type bytes and serialize it as "foo__b64_enc": b64(value), and deserializers strip and base64-decode. edit: it's exactly what you would do if you wanted to pass any binary data as json over the wire, regardless of whether you're using protobufs. you'd just get it "for free" (meaning you wouldn't have to write the boilerplate, not that you don't have to en/decode).
- skybrian 11y agoThere's no standard for this and it's mostly not open source as far as I know. The overall approach is called "JSPB" but there are various flavors. A typical use case is for a web app that has its own private RPC to its own servers, so interop isn't an issue. Also, web apps generally don't need or want to work with binary data, so better not to send it. I recently became the maintainer of the Dart protobuf library which supports both JSON and binary format [1], [2]. However, the JSON format isn't necessarily compatible with other protobuf libraries you've seen. [1] https://github.com/dart-lang/dart-protobuf https://github.com/dart-lang/dart-protobuf [2] https://github.com/dart-lang/dart-protoc-plugin https://github.com/dart-lang/dart-protoc-plugin