Is there any legal JSON that's not legal JavaScript?
If not, it's fair to say it's a subset.
Re:Unlocking the Power of JSON Patch
by tubthumper8 on Friday October 18, 2024 @03:38PM
(#41882750)
It is a subset as of JavaScript edition ES2019, when JavaScript strings are now allowed to contain U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR. Prior to ES2019, that was the only known example of legal JSON that was not legal JavaScript
JavaScript used to forbid U+2028 line separator and U+2029 paragraph separator in string literals, but JavaScript now allows them for compatibility with JSON.
The remaining wrinkle is different handling of "__proto__"
The most glaring issue is JSON number type versus JavaScript float. This causes issues in both directions whereby people consistently believe JSON can't represent numbers outside the float range and in addition JSON has no way to represent NaN.