Newtonsoft.Json.JsonConvert.SerializeObject
Take the following result :

&lt;script type="text/javascript"&gt;
    var json = { "key" : "&lt;/script&gt;" }
&lt;/script&gt;


Unless you HtmlEncoded your data somewhere, the "&lt;/script&gt;" will break your code. With Html Encoding, the result should look like this :

&lt;script type="text/javascript"&gt;
    var json = { "key" : "&amp;lt;/script&amp;gt;" }
&lt;/script&gt;


To easily encode all string, you can check this solution : http://pastebin.com/R2PWZkUq

Note that this should happen only with object declare inline. JSon coming from Ajax don't have this problem.