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

JsonFormat int64 converting #3194

Closed
z0mb1ek opened this issue Jun 7, 2017 · 1 comment
Closed

JsonFormat int64 converting #3194

z0mb1ek opened this issue Jun 7, 2017 · 1 comment

Comments

@z0mb1ek
Copy link

z0mb1ek commented Jun 7, 2017

Hi. Why int64(long in java) convert to string?

case INT64:       
case SINT64:
case SFIXED64:
          generator.print("\"" + ((Long) value).toString() + "\"");
          break;
@z0mb1ek z0mb1ek changed the title jsonprinter int64 converting JsonFormat int64 converting Jun 7, 2017
@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jun 7, 2017

It's required by proto3 JSON spec:
https://developers.google.com/protocol-buffers/docs/proto3#json

It's because int64 is not a standard JSON type and many JSON parsers don't support int64 precision. To avoid precision loss for int64, we decided to print int64 as strings in proto3 JSON.

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

4 participants