Is anyone familiar with a stable C++ solution (library, code snippet etc.) which converts protobuf messages to/from JSON?
A Printer converts protobuf message to JSON format. A TypeRegistry is used to resolve Any messages in the JSON conversion.
JSON is usually easier to debug (the serialized format is human-readable) and easier to work with (no need to define message types, compile them, install additional libraries, etc.). Protobuf, on the other hand, usually compresses data better and has built-in protocol documentation via the schema.
Protobuf supports more data types than JSON. JSON is limited to certain python objects, and it cannot serialize every python object. Protobuf supports a wider range of data types when compared to JSON. For example, enumerations and methods are supported by Protobuf and not supported by JSON.
Protobuf messages were 9% smaller than JSON messages and they took only 4% less time to be available to the JavaScript code.
This one is better IMO: https://github.com/shramov/json2pb
it does conversion in both directions and handles extensions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With