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

64bit numbers #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

mbennett2212
Copy link
Contributor

The proto3 JSON to protobuf mapping specifies behaviour for 64 bit numbers that protobuf2json-c does not currently follow:

  • 64 bit values will be written out as strings
  • Integers should be accepted as strings or number values

Update the protobuf2json-c package to implement the above behaviour.

Matt Bennett added 2 commits October 14, 2019 09:59
The proto3 json mapping specifies that 64 bit values will be written out
as strings. One reason for this is to prevent overflowing javascript
representation of numbers, which is limited to approximately 2^53.
The proto3 specification JSON mapping specifies that integers should be
accepted as strings or number values.

This patch adds support for this. It also checks whether the value is
within the range of the field that it is going into.  This prevents
wrapping due to typecasting.

64 bit integers are accepted as numbers, but this is only supported up to
a maximum of INT64_MAX, (jansson will reject values higher than this), so
it is advisable to use strings.
@mbennett2212
Copy link
Contributor Author

This fixes #11

@mbennett2212
Copy link
Contributor Author

These patches are based on top of PR #13 . The unit tests will not pass without that PR applied.

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

Successfully merging this pull request may close these issues.

1 participant