Skip to content

Conversation

@iovanom
Copy link
Contributor

@iovanom iovanom commented Nov 4, 2025

Related to #761

Signed-off-by: Ivan Majeru <ivanmajeru@gmail.com>
@Turings98apprentice
Copy link
Contributor

If you add just one more digit to the formatBase test, it fails. I think a true fix to this issue would involve incorporating something like BigDecimal. That being said, I think the issue this PR seeks to solve is better solved by simply using a string for large user IDs instead of integers.

image

@iovanom
Copy link
Contributor Author

iovanom commented Nov 5, 2025

Yes, it will fail, but not because of the JSONata library. JavaScript works that way. :)

You can see the example:

const a = 58908407122430764;
console.log(a); // output 58908407122430770
console.log(a.toString()) // the same 58908407122430770

const b = '58908407122430764';
const c = parseInt(b);
console.log(c); // output 58908407122430770

The fix is not related to the $fromBase function; it’s related to the $string function. The issue with the string implementation isn’t due to JavaScript limitations but rather the precision parameter within the JSONata library.

I completely agree that it’s better to have a string representation for the ID, but we can’t control the third-party API that returns the ID in number format.

@andrew-coleman andrew-coleman merged commit 6092352 into jsonata-js:master Nov 6, 2025
8 checks passed
@andrew-coleman
Copy link
Member

Thank you!

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.

3 participants