我已将 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/