![]() |
孤独的双杠 · 莫莉·奎恩 - 搜狗百科· 5 月前 · |
![]() |
乐观的熊猫 · java 问题排查 ...· 8 月前 · |
![]() |
独立的火龙果 · 济南市市场监督管理局 企业主体 ...· 11 月前 · |
![]() |
痴情的脆皮肠 · 囧叔时代 The Daily Show ...· 1 年前 · |
![]() |
慷慨大方的手套 · 王朝旗舰销量的秘密 ...· 1 年前 · |
我使用MVC4 web-api,c#,并希望使用Json.net.返回Json 。
问题是它伴随着“反斜线”。
我还将这段代码添加到Global.asax中。GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
以下是它返回的内容:
"{\"cid\":1,\"model\":\"WT50JB\",\"detail\":\"sdf??\",\"unit\":2,\"time_in\":\"2012-12-11T19:00:00\",\"time_out\":\"2012-12-12T13:00:06.2774691+07:00\",\"time_used_dd\":0.0,\"time_used_hh\":0.0}"
所以我想看到的是:{"cid":1,“WT50JB”,“WT50JB”,“detail”:“sdf?”,"unit":2,"time_in":"2012-12-11T19:00:00",time_in "time_used_dd":0.0,"time_used_hh":0.0}
这是JsonConvertor
string json = JsonConvert.SerializeObject(myObj);
发布于 2017-02-21 10:30:51
我找到了解决方案,而且它对我有用:
var json = JsonConvert.SerializeObject(sb.ToString(), Formatting.Indented);
response.Content = new StringContent(json, Encoding.UTF8 , "application/json");
https://stackoverflow.com/questions/13833900
复制相似问题
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2024 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号: 粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
![]() |
孤独的双杠 · 莫莉·奎恩 - 搜狗百科 5 月前 |