I have a json string like this: {\"active\": true} and I want replace for this {"active": true}. How can I do that in c#?
I tried jsonString.Replace("\\", "");
jsonString.Replace(@"\", "");
jsonString.Replace(@"\"", "");
nothing worked
I have a json string like this: {\"active\": true} and I want replace for this {"active": true}. How can I do that in c#?
I tried jsonString.Replace("\\", "");
jsonString.Replace(@"\", "");
jsonString.Replace(@"\"", "");
nothing worked
Since you want replace \"
to "
you can use Replace.("\\\"", "\"")
.
You need escape special characters like \
and "
. So \
becomes \\
, "
becomes \"
, and \"
becomes \\\"
.
Check Regex.Unescape(string) method. This method returns a new string without escape character.