I am trying to send a JSON string into Azure IoT Hub with the following format:
string format = "{\"info1\":\"info1Data\",\"info2\":\"info2Data\",\"info3\":{\"info3Data\":[]}}";
The problem is that after I serialize the string into a JSON Object it sends this to the IoT Hub :
{\"info1\":\"info1Data\",\"info2\":\"info2Data\",\"info3\":{\"info3Data\":[]}}
My goal is to remove the '\' character from the string sent to the IoT, and with that goal i tried several ways to work around this problem , such as :
var test= new string(format.ToCharArray());
test.Trim();
Console.WriteLine(test);
testing = test.Replace(@"\", "");
Console.WriteLine(testing);
OR
var charsToRemove = new string[] { @"\" };
foreach (var c in charsToRemove)
{
testing = testing.Replace(c, string.Empty);
}
Console.WriteLine(testing);
I'm using VS2019 and I still can't remove the '\' char from the string.
Thanks in advance.