changelog_unreleased/json/18405.md
json-stringify parser (#18405 by @fisker)Previous versions of Prettier json-stringify parser used JSON.stringify() to print numbers and strings. This led to the loss of the original value representation in a few rare cases. For example, extremely large or small numbers were rounded, and some special characters were unescaped. Technically, these transformations do not change how JSON values are read, but they are not something a formatter is concerned about. Prettier main now keeps the original representation, even if it can be simplified.
// Input
[
"\u00FF",
1e9999,
0.4e669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006,
-9223372036854775809,
1e3,
{
1e3: 1,
1e999999999999999999999999999999: 1,
1: 1
}
]
// Prettier stable
[
"ÿ",
null,
null,
-9223372036854776000,
1000,
{
"1000": 1,
"Infinity": 1,
"1": 1
}
]
// Prettier main
[
"\u00FF",
1e9999,
0.4e669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006,
-9223372036854775809,
1e3,
{
1e3: 1,
1e999999999999999999999999999999: 1,
"1": 1
}
]