I'm dealing with issue of backslashes in the string.
I have method like this
public IHttpActionResult GetResult()
{
return Ok(@"\");
}
But after JSON serialization I get this result in http response
"\\"
Is there any possibility to disable adding backslash during serialization? I know that I can do it by replacing \\ with \ before response but it is not elegant way for me.
You can't disable adding a backslash before a \
because it wouldn't be valid JSON (see here). The backaslash will always be added in the following cases:
But once your JSON is deserialized you should only get a single backslash for every \\
in your JSON string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With