News for hackers. Stuff that matters.
Re:Json ⊄ js by ricardobeat on Friday December 28, 2012 @12:34AM (#4976588)
Use data-* attributes [1], or print it in a script tag with a text/anything type:

    <script type="text/json" id="mydata">
        { data: "..." }
    </script>

    var data = JSON.parse($('mydata').textContent)
[1] https://developer.mozilla.org/en-US/docs/HTML/Global_attribu...
Re:Json ⊄ js by benmmurphy on Friday December 28, 2012 @07:42AM (#4977460)
If you put it in a script tag you need to ensure you escape </script>. Though, it is probably safer to escape <, >, and & just to be sure.
Re:Json ⊄ js by fforw on Friday December 28, 2012 @08:35AM (#4977607)
The </script> issue is why JSON and Javascript both allow you to escape the slash character with a backslash.

So just going <\/script> is enough.