Handling escape characters in JSON response in C#

前端 未结 2 1231
说谎
说谎 2021-01-27 19:36

I have a rather simple issue that for some reason I can find a help for using SO and Google. I am receiving a JSON reply that looks like this:

\"{
\\\"data\\\":          


        
相关标签:
2条回答
  • 2021-01-27 20:20

    Looks like you're getting confused by the value in the debugger. The debugger windows shows an escaped version of the string.

    enter image description here

    You can click on the little magnification icon to open the string in a "text visualizer" to see the actual value of the string.

    enter image description here

    0 讨论(0)
  • 2021-01-27 20:31

    You're trying to escape the \ character twice using regular escaping ("\\") and verbatim strings (@"string"). Try

    sContent = Regex.Replace(sContent, @"\", "");
    
    0 讨论(0)
提交回复
热议问题