Escape Quote in C# for javascript consumption

后端 未结 9 1259
天涯浪人
天涯浪人 2020-11-27 17:24

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\\\":[\";
         


        
9条回答
  •  孤街浪徒
    2020-11-27 18:05

    For .net 4.0 + there is standard HttpUtility.JavaScriptStringEncode

    For earlier west wind solution described by Lone Coder is quite nice

提交回复
热议问题