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

error in number serialization #2560

Closed
dsxmachina opened this issue Mar 27, 2023 · 5 comments
Closed

error in number serialization #2560

dsxmachina opened this issue Mar 27, 2023 · 5 comments

Comments

@dsxmachina
Copy link

Describe the bug
If you have serialized a 64-bit unsinged integer to json and you pipe the json through jq, the number will be changed into something else.

To Reproduce

echo '{"big-number":18446744073709551615}' | jq

Produces

{
  "big-number": 18446744073709552000
}

Expected behavior
18446744073709551615

Environment (please complete the following information):

  • Linux, NixOS 22.11
  • jq 1.6
@wader
Copy link
Member

wader commented Mar 27, 2023

Hi, have a look at

@notevenaperson
Copy link

notevenaperson commented Mar 29, 2023

@wader

$ jq --version
jq-1.6-145-ga9f97e9
$ echo '{"userId": 11111111112222222222}' | jq '.userId'
11111111112222222222

I think this issue will continue to be reported until you make a new release. Most users do not have the latest version because their distro doesn't follow git head. Not even bleeding-edge Arch Linux has this fix. A way to get distros to update would be a version 1.7.

@wader
Copy link
Member

wader commented Mar 29, 2023

Yeap hope we can do so also, see #2305 for current state of jq

@trothwell
Copy link

What does the JSON spec say about numbers?

The JSON Data Interchange Syntax ECMA-404
JSON instead offers only the representation of
numbers that humans use: a sequence of digits. All programming languages know how to make sense of digit
sequences even if they disagree on internal representations. That is enough to allow interchange.

I'd suggest that the internal representation be chosen by the user for backwards compatibility which was broken in jq-1.7 due to Decimal literal number #1752.

@nicowilliams
Copy link
Contributor

This is fixed in jq 1.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants