-
Notifications
You must be signed in to change notification settings - Fork 4
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
Very large number gets reformated as invalid JSON #27
Comments
Thanks for opening this issue. Maybe good to add dealing with a value having more than 16 digits, like I've had similar issues in my web application and implemented lossless-json to solve this (and there are quite a few similar Some ideas for a solution:
|
Thanks @josdejong . I appreciate the suggestions. There's already some logic that decides whether any given column of stuff contains reformattable numbers. ( Here's the relevant section in C# ). The existing logic gives up trying to reformat and justify the list if any of the numbers have too many digits or if the regular The underflow case is trickier. If I have a string like |
Ah, thanks for the pointer. So, would you like to alter the exponent like |
Fixed in versions 3.1.1 of the .NET and JS libraries. Fixed in version 3.1.2 of the VS Code extension. |
Thanks! |
As revealed in this issue, when attempting to justify a number list, FracturedJson will sometimes write very large numbers as "Infinity", without quotes, resulting in invalid JSON output.
The numbers for which this happens are ones that overflow a 64-bit float's range - for example,
1e500
. This happens when FJ tries to reformat numbers to align them, such as in a compact multiline array or table case.For instance, start this input:
Now reformat, using the settings,
DontJustifyNumbers=false
,MaxInlineComplexity=0
. The result is this:That's not valid JSON, which is a pretty bad mistake for a JSON formatter.
The following input creates similar problems:
It gets reformatted as:
This problem exists in the C# and JavaScript libraries, as well as the web-base formatter and the Visual Studio Code extension.
The text was updated successfully, but these errors were encountered: