3 ms·
JSON is derived from JavaScript, it is not a strict subset. The most glaring issue is JSON number type versus JavaScript float. This causes issues in both dire
by Guthur 2y ago
JSON is derived from JavaScript, it is not a strict subset.
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.
- bsimpson 2y agoIs there any legal JSON that's not legal JavaScript? If not, it's fair to say it's a subset.
- tubthumper8 2y agoIt 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
- fanf2 2y agoJavaScript 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__"