escape-html-in-json

1.0.0 • Public • Published

escape-html-in-json

Escape HTML entities in JSON.stringify, using a replacer method.

> var escape_html_entities = require('escape-html-in-json')
> var object = {name: "<script>alert('hacked');</script>"}
> JSON.stringify(object)
'{"name":"<script>alert(\'hacked\');</script>"}'
> JSON.stringify(object, escape_html_entities)
'{"name":"&lt;script&gt;alert(&#39;hacked&#39;);&lt;/script&gt;"}'

/escape-html-in-json/

    Package Sidebar

    Install

    npm i escape-html-in-json

    Weekly Downloads

    200

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • radagaisus