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.
Feature support #
- Firefox: supported since version 64
- Safari: supported since version 12.1