-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Values with large numbers getting changed #231
Comments
Thanks, this is a limitation in the Number format of JavaScript, which has a precision of about 16 digits. Solving this is not so trivial but interesting. It would require wirting our own JSON parser which keeps numbers in some string format instead of parse them as regular numbers. |
Any chance of supporting the "transit" format? https://github.com/cognitect/transit-format Of course, there are libraries for many languages, including JS :) https://github.com/cognitect/transit-js Because |
@aadrian this feature request has nothing to do with this issue, should be in it's own issue instead. Anyway, adding support for other data formats is not on the roadmap for JSONEditor, sorry. |
A short update on this topic: I've written a JavaScript a library which can handle large values without losing precision, see: https://github.com/josdejong/lossless-json I was planning on integrating this in the JSONEditor. Please note that relying on JSON objects containing for example 64bit long numbers may be tricky, since for example web applications cannot handle long values and will truncate some digits. |
That's great news! |
Yeah, still need to work that out. I'm focusing on a completely new version lately (see #337). |
@josdejong I've added BigInt support to json-source-map |
Cool 😎. I hadn't seen |
You use it here it seems :) |
Ah 😂 you're right. The code using |
@josdejong correct, this library is used by the selection api. |
this project now use i just want to upgrade |
upgrade |
|
what's the time (milestone) for fix this issue in jsoneditor project? |
Not anytime soon I expect. |
can you fix that now ? out project use this library... and we want to fix that; |
I would love to but there are simply so much things that I would like to address "now". I simply have a limited amount of spare time that I can spend on open source projects. If it's this important to you, you could implement it yourself and create a PR to get it merged into the project. Alternatively, you could try a workaround like adding a pre-processing step where you replace all long values in your JSON with strings before opening it in the JSONEditor, and a post-processing step where you do the opposite. |
let me try; or use string |
I am having this same issue. The program is converting an id 10120124111101040103 to a number 10120124111101040000. wilddynlan commented to use a string, how do you do that? I tried enclosing the number in double quotes, but that just makes the value "\"10120124111101040103\"". |
This is indeed still an open issue. The trick is to load JSON containing the large value as a string, so instead of: {
"large value": 10120124111101040103
} You provide the following document: {
"large value": "10120124111101040103"
} |
…within a option.
FYI: the successor of this library, svelte-jsoneditor, now supports lossless-json or other JSON parsers, and https://jsoneditoronline.org/ now uses this parser to handle large values. You can read more in the following article: https://jsoneditoronline.org/indepth/parse/why-does-json-parse-corrupt-large-numbers/ |
The following sample
{"abc":8143661439548533232}
is getting changed to following in the right panel
{"abc": 8143661439548533000}
The text was updated successfully, but these errors were encountered: