grpcurl icon indicating copy to clipboard operation
grpcurl copied to clipboard

Document "well known" protobuf types and their json mapping

Open adkafka opened this issue 5 years ago • 4 comments

I struggled to form the json payload for a gRPC service that used google's well-known timestamp defintion. I assumed the json for it would be:

{
  "field_name": {
    "seconds": 1500000000,
    "nanos": 1000
  }
}

Only by trial and error, did I figure out that grpcurl actually expects the timestamp to be an RFC string:

{
  "field_name": "2019-01-01T00:00:00Z"
}

I think this behavior (along with any other non-trivial mappings) should be documented on the README. I'm happy to make the PR for these additions, but I don't know where to find this mapping.

Thanks!

adkafka avatar Oct 09 '19 01:10 adkafka

This is standard JSON encoding for protocol buffers, which is already documented here: https://developers.google.com/protocol-buffers/docs/proto3#json

jhump avatar Oct 09 '19 14:10 jhump

got into same issue, and found solution only because of this thread I think the link you provided must be specified in README explicitly

glebarez avatar Nov 19 '21 12:11 glebarez

I want to add that I also think this should be documented explictly.

Also, this would be nice if we could deactivate the mapping. I am trying to write a e2e testing script that use grpcurl output to make assertions, but it is made difficult by the fact I have to use the formatted messages instead of the json

leandregagnonlewis avatar May 04 '23 18:05 leandregagnonlewis

Another day another encounter this :D Thanks @jhump for pointing JSON spec.

haunt98 avatar Aug 24 '23 04:08 haunt98