Escape Quote in C# for javascript consumption

后端 未结 9 1224
天涯浪人
天涯浪人 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 17:54

    Why don't you just do this:

    string correctResponseText = wrongResponseText.Replace("\"", "\\\"");
    

提交回复
热议问题