grpcurl icon indicating copy to clipboard operation
grpcurl copied to clipboard

I want grpcurl responses to use the same JSON field keys as documented in proto

Open shalako opened this issue 2 years ago • 1 comments
trafficstars

Given the following message in a protobuf file

message exampleMessage {
  string example_field = 1
}

When I use grpcurl to test this service, I currently receive a response which includes lowerCamelCase field names. This is unexpected.

{
"exampleField": "foo"
}

I expect the grpcurl output to use the same field names in the JSON response as found in proto, so that I can make sense of the protobuf file as documentation. Returning different field names is confusing.

{
"example_field": "foo"
}

I've tracked the issue down to grpcurl's use of json marshaler. I found that ProtoJSON offers an option to use the original proto names: https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson; see UseProtoNames. I would like to option to enable display of original field names.

shalako avatar Feb 08 '23 00:02 shalako