I'm getting JSON from a server in string format and I am saving it to a text file
Then I'm reading that text file and giving it back to the server but there I'm not able to parse it back to an object. It may be because the escape sequence are causing the problem or I don't know.
Please suggest, I'm using C# and Newtonsoft's JSON.NET
Here are the samples:
String received from server and saving this to local txt file
{"data":"[{\"MenuId\":483,\"Name\":\"Nikhil menu\",\"Desc\":\"test\",\"ASAP\":\"T\",\"LT\":\"T\",\"FO\":\"T\",\"catList\":[{\"CatId\":5132,\"CatName\":\"Cate00\",\"Desc\":\"test\",\"P1\":{\"Id\":1,\"Name\":\"SML\"},\"P2\":{\"Id\":2,\"Name\":\"MED\"},\"P3\":null,\"P4\":null,\"P5\":null,\"P6\":null,\"CatType\":\"Normal\",\"ItemList\":[{\"Id\":38190,\"Name\":\"XXX\",\"Desc\":\"tesdt\",\"MinQ\":1,\"MaxQ\":99,\"MinP\":0.0,\"MaxP\":0.0,\"P1\":100.0,\"P2\":200.0,\"P3\":-99.0,\"P4\":-99.0,\"P5\":-99.0,\"P6\":-99.0,\"Img\":\"\",\"Icon1\":null,\"Icon2\":null,\"Icon3\":null,\"Icon4\":null,\"OpenOn\":{\"Mon\":\"T\",\"Tue\":\"T\",\"Wed\":\"T\",\"Thu\":\"T\",\"Fri\":\"T\",\"Sat\":\"T\",\"Sun\":\"T\"},\"SpecialOffer\":null,\"AddOnList\":[],\"ItemModList\":[]}]}]}]","message":"Processed Successfully","serviceName":"CreateCache","serviceStatus":"S"}
string after reading the same local text file from the server
{"data":"[{\"MenuId\":483,\"Name\":\"Nikhil menu\",\"Desc\":\"test\",\"ASAP\":\"T\",\"LT\":\"T\",\"FO\":\"T\",\"catList\":[{\"CatId\":5132,\"CatName\":\"Cate00\",\"Desc\":\"test\",\"P1\":{\"Id\":1,\"Name\":\"SML\"},\"P2\":{\"Id\":2,\"Name\":\"MED\"},\"P3\":null,\"P4\":null,\"P5\":null,\"P6\":null,\"CatType\":\"Normal\",\"ItemList\":[{\"Id\":38190,\"Name\":\"XXX\",\"Desc\":\"tesdt\",\"MinQ\":1,\"MaxQ\":99,\"MinP\":0.0,\"MaxP\":0.0,\"P1\":100.0,\"P2\":200.0,\"P3\":-99.0,\"P4\":-99.0,\"P5\":-99.0,\"P6\":-99.0,\"Img\":\"\",\"Icon1\":null,\"Icon2\":null,\"Icon3\":null,\"Icon4\":null,\"OpenOn\":{\"Mon\":\"T\",\"Tue\":\"T\",\"Wed\":\"T\",\"Thu\":\"T\",\"Fri\":\"T\",\"Sat\":\"T\",\"Sun\":\"T\"},\"SpecialOffer\":null,\"AddOnList\":[],\"ItemModList\":[]}]}]}]","message":"Processed Successfully","serviceName":"CreateCache","serviceStatus":"S"}
string which I get after adding it to and object of another class which I use to send it over again to server and I get this string on server
{"data":"[{\"MenuId\":483,\"Name\":\"Nikhil menu\",\"Desc\":\"test\",\"ASAP\":\"T\",\"LT\":\"T\",\"FO\":\"T\",\"catList\":[{\"CatId\":5132,\"CatName\":\"Cate00\",\"Desc\":\"test\",\"P1\":{\"Id\":1,\"Name\":\"SML\"},\"P2\":{\"Id\":2,\"Name\":\"MED\"},\"P3\":null,\"P4\":null,\"P5\":null,\"P6\":null,\"CatType\":\"Normal\",\"ItemList\":[{\"Id\":38190,\"Name\":\"XXX\",\"Desc\":\"tesdt\",\"MinQ\":1,\"MaxQ\":99,\"MinP\":0.0,\"MaxP\":0.0,\"P1\":100.0,\"P2\":200.0,\"P3\":-99.0,\"P4\":-99.0,\"P5\":-99.0,\"P6\":-99.0,\"Img\":\"\",\"Icon1\":null,\"Icon2\":null,\"Icon3\":null,\"Icon4\":null,\"OpenOn\":{\"Mon\":\"T\",\"Tue\":\"T\",\"Wed\":\"T\",\"Thu\":\"T\",\"Fri\":\"T\",\"Sat\":\"T\",\"Sun\":\"T\"},\"SpecialOffer\":null,\"AddOnList\":[],\"ItemModList\":[]}]}]}]","message":"Processed Successfully","serviceName":"CreateCache","serviceStatus":"S"}
I am not able to parse this string file back to List
I have tried
JObject jObject = JObject.Parse(obj.cacheInfo.cData);
JToken jT = jObject["data"];
List<Menu> lMenu = JsonConvert.DeserializeObject<List<Menu>>(jT.ToString());
JObject jObject = JObject.Parse(obj.cacheInfo.cData);
JObject jObject = JObject.Parse(jObject["data"].ToString());
any help will do, thanks
"message":"Processed Successfully","serviceName":"CreateCache","serviceStatus":"S"}