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
json.dumps(instance)
which raised TypeError(repr(o) + " is not JSON serializable")
instance.to_json()
(or alike) functionHow do I serialize a Python proto object to JSON?
There is a function MessageToJson
in the json_format
module. This function can be used to serialize the message.