JSON.stringify was previously specified to return ill-formed Unicode strings if the input contains any lone surrogates:
// → '"�"'
JSON.stringify” proposal changes
JSON.stringify so it outputs escape sequences for lone surrogates, making its output valid Unicode (and representable in UTF-8):
// → '"\\ud800"'
JSON.parse(stringified) still produces the same results as before.
- Firefox: 自 64 版开始支持
- Safari: 支持
- Babel: 不支持