I have a ASP.Net web handler that returns results of a query in JSON format
public static String dt2JSON(DataTable dt) { String s = \"{\\\"rows\\\":[\";
For .net 4.0 + there is standard HttpUtility.JavaScriptStringEncode
HttpUtility.JavaScriptStringEncode
For earlier west wind solution described by Lone Coder is quite nice