pythonjsonserializationprotocol-buffers-3

Protobuf3: Serialize a Python object to JSON


According to the manual, Protobuf 3.0.0 supports JSON serialization:

A well-defined encoding in JSON as an alternative to binary proto encoding.

What have I tried

How do I serialize a Python proto object to JSON?


Solution

  • There is a function MessageToJson in the json_format module. This function can be used to serialize the message.