C# .NET PostSubmitter发送反斜杠
我使用C#将JSON发送到PHP脚本,如下所示:C# .NET PostSubmitter发送反斜杠,c#,.net,json,http-post,backslash,C#,.net,Json,Http Post,Backslash,我使用C#将JSON发送到PHP脚本,如下所示: string json = "{"; json += "\"prop\":\"some text\""; json += "}"; PostSubmitter post = new PostSubmitter(); post.Url = "http://localhost/synch/notein.php"; post.Type = PostSubmitter.PostTypeEnum.Post; post.PostItems.Add("not
string json = "{";
json += "\"prop\":\"some text\"";
json += "}";
PostSubmitter post = new PostSubmitter();
post.Url = "http://localhost/synch/notein.php";
post.Type = PostSubmitter.PostTypeEnum.Post;
post.PostItems.Add("note", json);
post.Post();
当然,我将不得不转义内部引号,但它们会被发送到脚本中!更糟糕的是:文本中已经有引号,所以必须将它们转义为有效的JSON。在这种情况下,我希望传输反斜杠。有没有办法做到这一点?为什么不将自定义对象序列化为json结果呢。这样,您就不必担心转义,框架将。。。下面是一个使用-摆脱反斜杠的示例
\
:
json += "\\\"prop\":\\\"some text\\\"";
哦,虽然PostSubmitter来自.NET框架,但它是第三方的。然而:事实证明这是一个PHP问题。如果有人有类似的问题:在PHP文档中查找get_magic_quotes_gpc