Erik Bergstedt
Erik Bergstedt

Reputation: 912

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..

Upvotes: 0

Views: 643

Answers (1)

Aesthete
Aesthete

Reputation: 18848

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!

Upvotes: 2

Related Questions