1. 程式人生 > >C#WebAPI返回json去掉雙引號前面的反斜槓

C#WebAPI返回json去掉雙引號前面的反斜槓

string str="{\"msgType\":1001,\"msgstring\":\"資訊\"}";//這裡是你的json帶有反斜槓的
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") };//這裡是去掉反斜槓再放回出去,json就只剩下雙引號。
            return result;