Encode ±INFINITY as ±1e5000

The V8 behavior of encoding infinity as null doesn't make sense to me.
Using ±1e5000 is better, because JSON.parse decodes it as INFINITY and
the information is preserved. This could be a breaking change for some
This commit is contained in:
Justine Tunney 2024-06-01 03:15:23 -07:00
parent 9b6718ac99
commit fae1c32267
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
3 changed files with 7 additions and 12 deletions

View file

@ -38,7 +38,7 @@ char* DoubleToJson(char buf[128], double x) {
static const DoubleToStringConverter kDoubleToJson(
DoubleToStringConverter::UNIQUE_ZERO |
DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN,
"null", "null", 'e', -6, 21, 6, 0);
"1e5000", "null", 'e', -6, 21, 6, 0);
kDoubleToJson.ToShortest(x, &b);
b.Finalize();
if (READ32LE(buf) != READ32LE("-nul")) {