I have a this method to serialise objects to json.
public string SerialiseObject(object obj)
{
using (var dataStream = new MemoryStream())
using (var reader = new StreamReader(dataStream))
{
var objSer = new DataContractJsonSerializer(obj.GetType());
objSer.WriteObject(dataStream, obj);
dataStream.Position = 0;
var bytes = Encoding.UTF8.GetBytes(reader.ReadToEnd());
return Encoding.UTF8.GetString(bytes);
}
}
It was working fine for all my objects unless I have this new property which holds a url in it.
MyObject.StoreUrl = "https://www.myCoffeeShop.com";
now when I use my serialize method it generates
"StoreUrl": "https:\/\/www.myCoffeeShop.com"
while I am expecting
"StoreUrl": "https://www.myCoffeeShop.com"
Can someone please tell me what am I missing?