JSON5 : JSON with superpower

artydev - Jan 14 '21 - - Dev Community

Have you ever wanted to use multilines strings in JSON objects ?
JSON5 allows that and much more

You can test it here : JSON5-TEST

<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>

<script>
  const mscripts = { 
    hello : `
      function hello() {
        alert('hello from JSON5')
      };
      hello();
      `
  }
  let str = JSON5.stringify(mscripts) 
  let res  = JSON5.parse(str) 
 eval(mscripts.hello) 
</script>
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player