string-template-format-json

String template literal tag that converts values to JSON text

Usage no npm install needed!

<script type="module">
  import stringTemplateFormatJson from 'https://cdn.skypack.dev/string-template-format-json';
</script>

README

String Template Format: JSON

String template literal tag that converts values to JSON text

Usage

import json from 'string-template-format-json'
console.log(json`number ${123}; string: ${'abc'}; object: ${{ abc: 123 }}; array: ${[0, 1, 2]}`)

should print:

number: 123; string: "abc"; object: {"abc":123}; array: [0,1,2]

License

MIT © Hoàng Văn Khải