grpcurl
grpcurl copied to clipboard
Document "well known" protobuf types and their json mapping
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!
This is standard JSON encoding for protocol buffers, which is already documented here: https://developers.google.com/protocol-buffers/docs/proto3#json
got into same issue, and found solution only because of this thread I think the link you provided must be specified in README explicitly
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
Another day another encounter this :D Thanks @jhump for pointing JSON spec.