JSPM

escape-html-in-json

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2246
  • Score
    100M100P100Q118580F
  • License MIT

Escape HTML entities in JSON.stringify()

Package Exports

  • escape-html-in-json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (escape-html-in-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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;"}'