Parse json string to dataset in C#.
// 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));


Amit MohantyPosted Dec 19, 2018, 12:42 AM EST
Public DataSet jsonToDataSet(string jsonString) { try { XmlDocument xd = new XmlDocument(); jsonString = "{ \"rootNode\": {" + jsonString.Trim().TrimStart('{').TrimEnd('}') + "} }"; xd = (XmlDocument)JsonConvert.DeserializeXmlNode(jsonString); DataSet ds = new DataSet(); ds.ReadXml(new XmlNodeReader(xd)); return ds; } catch (Exception ex) { throw new ArgumentException(ex.Message); } }
prdip vaddoriyaPosted Feb 20, 2015, 1:21 AM EST
your mentioned code is not compatible with this above response string
prdip vaddoriyaPosted Feb 20, 2015, 1:20 AM EST
when i call my webservice function ..it will return this string to me. ["[{"SetupID":"1","SetupName":"fgdhgf","DynamicSetup":"0","EventWiseRecording":"0","LiveViewLoadSharing":"0","StorageLoadSharing":"0","SnapshotPath":"d:\temprec","LocalVideoRecordingPath":"d:\temprec","HighlightMarkedLocation":"0","IsInInteranet":"1","LogoPath":"E:\pradip\Work\Vizio360 Product\Viziosecure360-Supervisor\VizioSecure360-Supervisor\bin\Debug\Company_Logo.png","Address":"hfjdfhj","FTPUpload":"0"}]"] ====================>> How to convert it in dataset