Regex to replaces slashes inside of JSON Regex to replaces slashes inside of JSON json json

Regex to replaces slashes inside of JSON


To replace single backslashes with double backslashes, but leave existing doubles alone, search for

(?<!\\)\\(?!\\)

and replace that with

\\\\

For C#, RegexBuddy creates this code snippet:

resultString = Regex.Replace(subjectString,     @"(?<!\\)  # lookbehind: Check that previous character isn't a \    \\         # match a \    (?!\\)     # lookahead: Check that the following character isn't a \",     @"\\", RegexOptions.IgnorePatternWhitespace);


What is the Error? what is your deserializeObject?

If you use something like :

data = JsonConvert.DeserializeObject<Dictionary<Object, Object>>(jsonText);

You shouldn't have any problems.