How to parse json string to dataset in C#
Posted
by
Samir R. Bhogayta
on Samir ASP.NET with C# Technology
See other posts from Samir ASP.NET with C# Technology
or by Samir R. Bhogayta
Published on 2014-04-17T17:52:00.004+05:30
Indexed on
2014/05/26
21:58 UTC
Read the original article
Hit count: 214
Filed under:
// Serialization of DataSet to json string
StringWriter sw = new StringWriter();
versionUpGetData.WriteXml(sw, XmlWriteMode.WriteSchema);
XmlDocument xd = new XmlDocument();
xd.LoadXml(sw.ToString());
String jsonText = JsonConvert.SerializeXmlNode(xd);
File.WriteAllText(“d:/datasetJson.txt”,jsonText);
//Deserialization of Json String to DataSet
XmlDocument xd1 = new XmlDocument();
xd1 = (XmlDocument)JsonConvert.DeserializeXmlNode(jsonText);
DataSet jsonDataSet = new DataSet();
jsonDataSet.ReadXml(new XmlNodeReader(xd1));
StringWriter sw = new StringWriter();
versionUpGetData.WriteXml(sw, XmlWriteMode.WriteSchema);
XmlDocument xd = new XmlDocument();
xd.LoadXml(sw.ToString());
String jsonText = JsonConvert.SerializeXmlNode(xd);
File.WriteAllText(“d:/datasetJson.txt”,jsonText);
//Deserialization of Json String to DataSet
XmlDocument xd1 = new XmlDocument();
xd1 = (XmlDocument)JsonConvert.DeserializeXmlNode(jsonText);
DataSet jsonDataSet = new DataSet();
jsonDataSet.ReadXml(new XmlNodeReader(xd1));
© Samir ASP.NET with C# Technology or respective owner