Escape characters after Serializing using Json

后端 未结 3 666
梦谈多话
梦谈多话 2021-01-27 11:15

Y is my object being serialized in a weird manner while using newtonsoft.json from ASP.Net Web API?

var s = JsonConvert.SerializeObject(request, For         


        
3条回答
  •  [愿得一人]
    2021-01-27 11:44

    There's nothing to be worried about here. This is the correct serialized object json. It is appearing like this because you are viewing this in visual studio by hovering variable to view its value, because in c# \" is used to represent a " in a string. When you will write this value in a text file(just to test actual value) , you will see what is it's actual value as:

      string json="{\"head\":{\"version\":\"1.0\",\"serial\":\"20140102,6,125\",\"skinId\":\"Test\"";
    
        File.WriteAllText("c:\\tests on.txt",json) ;
    

    You will see the json in file what you actually want.

提交回复
热议问题