Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Protobuf to/from JSON conversion [closed]

Tags:

Is anyone familiar with a stable C++ solution (library, code snippet etc.) which converts protobuf messages to/from JSON?

like image 694
Zaur Nasibov Avatar asked Aug 10 '11 08:08

Zaur Nasibov


People also ask

Can we convert Protobuf to JSON?

A Printer converts protobuf message to JSON format. A TypeRegistry is used to resolve Any messages in the JSON conversion.

Is Protobuf more efficient than JSON?

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.

Should I use Protobuf or JSON?

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.

Is Protobuf lighter than JSON?

Protobuf messages were 9% smaller than JSON messages and they took only 4% less time to be available to the JavaScript code.


1 Answers

This one is better IMO: https://github.com/shramov/json2pb

it does conversion in both directions and handles extensions

like image 167
haberlerm Avatar answered Sep 19 '22 02:09

haberlerm