I am struggling with a string
"[{\"Item\": { \"Name\": \"item1\" }, \"ShipQuantity\": \" 50.0000000000000000000\", \"Total\": \"10.0000000000000000000\"},{\"Item\": { \"Name\": \"Gratuity\" }, \"ShipQuantity\": \" 1.0000000000000000000\", \"Total\": \"10.0000000000000000000\"}]"
i need the string exact like this
[{"Item": { "Name": "item1" }, "ShipQuantity": " 50.0000000000000000000", "Total": "10.0000000000000000000"},{"Item": { "Name": "Gratuity" }, "ShipQuantity": " 1.0000000000000000000", "Total": "10.0000000000000000000"}]"
But either not able to remove slashes from it, i tried
var string = "[{\"Item\": { \"Name\": \"item1\" }, \"ShipQuantity\": \" 50.0000000000000000000\", \"Total\": \"10.0000000000000000000\"},{\"Item\": { \"Name\": \"Gratuity\" }, \"ShipQuantity\": \" 1.0000000000000000000\", \"Total\": \"10.0000000000000000000\"}]";
string = string.Replace(@"\","");
But its not replacing it.
The best way to remove all escape characters from your
JSONstring is to use theRegex.Unescape()method. This method returns a new string with no escape characters. Even characters such as\n\tetc are removed.Make sure to import the
System.Text.RegularExpressionsnamespace:More information on this method can be found here