Escape a JSON string so it is safe to embed inside an inline <script> element.
<script>
The result is still valid JSON: only characters that are dangerous in the HTML/JS host context are replaced by their equivalent \uXXXX escapes.
\uXXXX
A JSON string (typically from JSON.stringify).
JSON.stringify
The escaped, embed-safe JSON string.
escapeSnapshotJson('{"bio":"</script>"}')// => '{"bio":"\\u003C/script\\u003E"}' Copy
escapeSnapshotJson('{"bio":"</script>"}')// => '{"bio":"\\u003C/script\\u003E"}'
Escape a JSON string so it is safe to embed inside an inline
<script>element.The result is still valid JSON: only characters that are dangerous in the HTML/JS host context are replaced by their equivalent
\uXXXXescapes.