Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document "well known" protobuf types and their json mapping #121

Open
adkafka opened this issue Oct 9, 2019 · 4 comments
Open

Document "well known" protobuf types and their json mapping #121

adkafka opened this issue Oct 9, 2019 · 4 comments

Comments

@adkafka
Copy link

adkafka commented Oct 9, 2019

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!

@jhump
Copy link
Contributor

jhump commented Oct 9, 2019

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

@glebarez
Copy link

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

@leandregagnonlewis
Copy link

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

@haunt98
Copy link

haunt98 commented Aug 24, 2023

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

haunt98 added a commit to haunt98/posts-go that referenced this issue Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants