0
List<myClass>() myList= new List<myClass>();
myList.add(new myClass(){ ID=2,Name="2" });
JsonConvert.SerializeObject(myList);

output :

[{\"ID\":2,\"FullName\":\"2\"}]

How can I prevent backslash?

  • 2
    Does this answer your question? [Newtonsoft.Json SerializeObject without escape backslashes](https://stackoverflow.com/questions/20312974/newtonsoft-json-serializeobject-without-escape-backslashes) – Yong Shun Jun 24 '21 at 00:23

1 Answers1

0

In C# when convert an object to json string, it is just a string. In VS studio double quotes must be escaped. So the result you received is correct. Other wise compiler will not be able to compile that string.

When you debug this you can see the string as you want in text preview.

Darshani Jayasekara
  • 561
  • 1
  • 4
  • 14