Skip to content Skip to sidebar Skip to footer

Make Grpc Messages Json Serializable

I have a gRPC definition that contains repeated scalar values. For example message Request { bool dryrun = 1; bool verbose = 2; bool enabled = 3; float ratio = 4; int

Solution 1:

Solved it myself.

There is an option including_default_value_fields with json_format.MessageToJson(). When set to False, all default fields are not printed to JSON, although they are physically sent through the wire.

Unfortunately, the option was turned off by default.

After setting it to True, the problem is gone.

Post a Comment for "Make Grpc Messages Json Serializable"