5

Protobuf is in binary format, and it has also equivalent text format and JSON format.

protoc has --encode and --decode option to do text-binary conversion.

But is there a small tool to do JSON-binary conversion? like below:

tool --encode input.json def.proto  > pb-output.bin

and

tool --decode pb-input.bin def.proto > output.json

Thanks!

Wei Huang
  • 590
  • 1
  • 5
  • 18
  • Take a look at [proto-convert](https://github.com/iamAzeem/proto-convert). – Azeem Jul 07 '20 at 16:01
  • Thanks @Azeem. Did you create the tool for this question, ;), since I see it's less than a day? – Wei Huang Jul 08 '20 at 04:03
  • 1
    Well, kind of and you're welcome! :-) Not completely true, though. ;-) I wrote this plugin earlier: [fluent-plugin-protobuf-http](https://github.com/iamAzeem/fluent-plugin-protobuf-http). So, I already had an idea and other POCs on how to go about it. See: [protobuf-log-sample](https://github.com/iamAzeem/protobuf-log-sample) and [protobuf-repeated-type-vs-any](https://github.com/iamAzeem/protobuf-repeated-type-vs-any). So, your question expedited its materialization. Cheers! :-) – Azeem Jul 08 '20 at 04:13

0 Answers0