c# - 由于意外字符串 (WCF + JSON),WCF 响应无效

标签 c# .net wcf json

我已将 WCF 服务配置为使用 JSON。 我遇到了所有条目都被转义的问题。

    [
   {
      "rel":"http:\/\/localhost:3354\/customer\/1\/order",
      "uri":"http:\/\/localhost:3354\/customer\/1\/order\/3"
   },
   {
      "rel":"http:\/\/localhost:3354\/customer\/1\/order",
      "uri":"http:\/\/localhost:3354\/customer\/1\/order\/5"
   },
   {
      "rel":"http:\/\/localhost:3354\/customer\/1\/order",
      "uri":"http:\/\/localhost:3354\/customer\/1\/order\/8"
   }
]

我确信消息是有效的,默认情况下不需要转义它,是否可以关闭某些字段的转义?

最佳答案

JSON spec转义斜杠。

char any-Unicode-character- except-"-or--or- control-character \" \ \/ \b \f \n \r \t \u four-hex-digits

因此:C# 中的“/”在 JSON 中变成了“\/”

关于c# - 由于意外字符串 (WCF + JSON),WCF 响应无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5354719/

相关文章:

c# - 为什么 WCF 使用具有不同签名的新方法生成代理包装契约接口(interface)方法?

.net - 如何选择 WCF 绑定(bind)?

c# - 我收到以下错误 "AADSTS90002 Tenant authorize not found."

c# - 当绑定(bind)属性强制执行某些业务规则时,绑定(bind) WPF TextBox 不会更新值

c# - ReSharper 代码注释异步任务<T>

.net - 哪个 ORM 工具支持 Microsoft Access?

c# - DataGridViewCheckBoxCell 如何在表单加载期间设置时显示已选中

c# - 如何按日期时间元素对自定义数组列表进行排序

c# - 监控连接到网络的客户端

.net - 当前禁用了此服务的WCF元数据发布+内容类型错误