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

Go gRPC Gateway - Type of one field in JSON is not same as in proto #1201

Closed
xs2tarunkukreja opened this issue Apr 8, 2020 · 3 comments
Closed

Comments

@xs2tarunkukreja
Copy link

We have one gRPC Go server which is wrapped by Grpc Gateway. So, out web portal is communicated with Gateway in Http protocol and internally gRPC gateway and gRPC server are communicating by gRPC protocol.

Most of the call is working fine. Only one call response is having an issue. Type specified in proto file is integer but JSON response having type as String.

Some useful details -
We are having 2 protos file - One file is imported in another proto file.

Type issue is coming in imported file message.

@johanbrandhorst
Copy link
Collaborator

I'm reading between the lines here, but I assume you're using a int64 or uint64 type for this field? See #438 for more discussion, but the short answer is, JSON doesn't support the full range of 64bit integers, so we're forced to use strings to be accurate for large numbers. I will preemptively close this, but please let me know if I've misunderstood.

@xs2tarunkukreja
Copy link
Author

Yeah, we are using int64. But the value of the same is small. In past, before using go, code was written in Node JS and JSON was supporting that value.

@johanbrandhorst
Copy link
Collaborator

You can use an int32 type and it will use an integer in the return value.

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

2 participants