-
Notifications
You must be signed in to change notification settings - Fork 123
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
Use JSON11 to parse and serialize long numerals #784
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some of the CI has failed, take a look?
Are _stringifyWithBigInt
and _parseWithBigInt
used anywhere after this or are they dead code? Remove.
Are there tests for this that do big ints that cover these paths?
What are the performance numbers, even if anecdotal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is JSON11
a superset of sjson
? Why not just use that in all cases and get rid of all the special handling of big ints?
Would it make sense to let users configure the serializer/deserializer instead of having special handling of big ints and importing mutliple libraries?
Signed-off-by: Miki <[email protected]>
Removed dead code.
Yes; I cleaned them up to remove the unnecessary tests.
An experiment with 10,000 false positives took over 90s earlier. With JSON11, it takes 200-ish ms.
Fixed. |
JSON11 is a superset of JSON5 which is spec-wise a superset of JSON. By contrast,
It is a user provided option named |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better than the previous custom implementation, so good to go.
Generally, in the combination of shouldHandleLongNumerals=true
, numeralsAreNumbers
getting set by the first parse, and JSON11.stringify
succeeding, we parse twice.
This just begs the question of why all this complication, what would not be possible if the caller specified that they want to use JSON
vs. JSON11
vs. JSONXYZ
instead of enableLongNumeralSupport
?
On a side note: I believe the way |
I don't think I understand this, but open issues! |
I am glad I was able to make time for this.
I could just make it look at
That is certainly an option but for mixed-use customers, it would lead to maintaining too many options. |
Description
Changing from the RegEx based approach to an AST one dramatically reduces the encounters with false-positives, reducing the amount of time it takes to parse very large values.
Check List
yarn run lint
doesn't show any errorsBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.