简体   繁体   中英

Replacing \“ with ” in a string (C#)

I have a JSON looking like this

"{\"jquery\": [[0, 1, \"call\", [\"body\"]] etc

This is obviously wrong and I want to replace the \\" parts with " to get the formatting correct.

I've tried so many things.. "\\\\"", "\\"", System.Environment.Newline, I can't get anything to work in String.Replace..

I think you are confused..

If you have a string like so, defined somewhere in you C# project:

String str = "Foo is \"bar is\" Baz!";

It will show the same way in the debugger when you view it. The escape character \\ is saying, don't end my string here, this " is part of the string.

If you put the following line,

Console.Write(str);

You should see this output.

Foo is "bar is" Baz!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM