.NET PostSubmitter sends backslashes

Posted by Stefan N. on Stack Overflow See other posts from Stack Overflow or by Stefan N.
Published on 2010-04-18T15:51:23Z Indexed on 2010/04/18 15:53 UTC
Read the original article Hit count: 395

Filed under:
|
|
|
|

Hi, I'm using C# to send JSON to a PHP-Script, like this:

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();

Of course I'll have to escape the inner quotes, but they get sended to the script! To make things worse: There is text, which already has quotation marks, so those must be escaped to be valid JSON. In this case I want the backslashes to be transmitted. Any idea to accomplish this?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#