C#WebAPI返回json去掉双引号前面的反斜杠

来源:互联网 发布:虚拟变量数据什么意思 编辑:程序博客网 时间:2024/05/21 07:05
 
string str="{\"msgType\":1001,\"msgstring\":\"信息\"}";//这里是你的json带有反斜杠的
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") };//这里是去掉反斜杠再放回出去,json就只剩下双引号。            return result;
0 0