2

I am using Json.Net to convert a DataTable to JSON as mentioned below, but my JSON string contains backslash characters \ before the quotation marks. How can I remove these characters?

C# Code to convert DataTable to JSON string:

string json = JsonConvert.SerializeObject(objAcctDTable, Formatting.None);

Json Output String:

"[{\"AcctID\":5822,\"AcctName\":\"1 EDI SOURCE INC (Vendor)\"},{\"AcctID\":4350,\"AcctName\":\"21C OATS, INC. (Rail Customer)\"},{\"AcctID\":5729,\"AcctName\":\"24 Waterway LLC (Leasing Company Account)\"},{\"AcctID\":3799,\"AcctName\":\"3D CORPORATE SOLUTIONS LLC (Rail Customer)\"},{\"AcctID\":4596,\"AcctName\":\"3FNP (HINES 70 WEST MADISON LP) (Vendor)\"},{\"AcctID\":6035,\"AcctName\":\"3FNP LLC (Oracle Vendor)\"},{\"AcctID\":4622,\"AcctName\":\"3M CO (Vendor)\"},{\"AcctID\":4532,\"AcctName\":\"3M COMPANY (Oracle Customer)\"},{\"AcctID\":5912,\"AcctName\":\"5th3rd, BCC (Leasing Company Account)\"},{\"AcctID\":5913,\"AcctName\":\"5th3rd, UBOC, FNBC (Leasing Company Account)\"},{\"AcctID\":5730,\"AcctName\":\"8121 Broadway Interests, LLC (Leasing Company Account)\"},{\"AcctID\":3324,\"AcctName\":\"A E STALEY MFG. (Mileage Tax Customer)\"}]"
Brian Rogers
  • 125,747
  • 31
  • 299
  • 300
  • I have experienced the same issue before, its most probably the debugger doing this. As you can `Console.WriteLine` the string and see the json without the back-slash – Mike Barnes Mar 05 '15 at 10:59
  • Is it escaped while viewing in your debugger, or also when printed on the console? – klekmek Apr 14 '21 at 12:55

0 Answers0