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

Rust: Render 64-bit and larger integers as strings in JSON #181

Open
leighmcculloch opened this issue Nov 13, 2023 · 1 comment
Open

Rust: Render 64-bit and larger integers as strings in JSON #181

leighmcculloch opened this issue Nov 13, 2023 · 1 comment
Assignees

Comments

@leighmcculloch
Copy link
Member

What

Render 64-bit integers as strings in JSON.

Why

JS runtimes cannot correctly decode JSON numbers greater than 53-bits.

@leighmcculloch
Copy link
Member Author

leighmcculloch commented Nov 25, 2023

Given that so many tools support 64-bit integers in JSON I'm thinking maybe we should follow a pattern I've heard folks using, where the 64-bit integer is encoded into two fields, in a number in a field by it's native name, and in a string in a field by its native name suffixed with _str.

For example:

{
    "my_field": 1,
    "my_field_str": "1",
    // ...

The downside of this is that someone may still use the my_field in JS and unknowingly be interpreting the JSON data as a Number with lost precision.

@leighmcculloch leighmcculloch changed the title Rust: Render 64-bit integers as strings in JSON Rust: Render 64-bit and larger integers as strings in JSON Mar 21, 2024
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

1 participant