fullstorydev / grpcurl

Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers
MIT License
10.36k stars 497 forks source link

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

Open shalako opened 1 year ago

shalako commented 1 year ago

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.