mcpwn API
    Preparing search index...

    Function escapeJsonForScript

    • Make a JSON string safe to embed inside a <script type="application/json"> element. JSON.stringify does not escape <, so a payload containing </script> would otherwise close the element and inject markup; neutralise the three characters that matter (<, >, &). The blob is parsed as JSON, not executed, so JS-only concerns (U+2028/2029) do not apply here.

      Parameters

      • json: string

      Returns string