Sometimes we need to convert json to dataset in that case following code snippet will help us.
Code snippet :
public DataSet ConvertJsonToDataSet(string jsonString)
{
XmlDocument xd = new XmlDocument();
jsonString = "{ \"myrootNode\": {" + jsonString.Trim().TrimStart('{').TrimEnd('}') + "} }";
xd = (XmlDocument)JsonConvert.DeserializeXmlNode(jsonString);
DataSet ds = new DataSet();
ds.ReadXml(new XmlNodeReader(xd));
return ds;
}
Happy Coding !!
Code snippet :
public DataSet ConvertJsonToDataSet(string jsonString)
{
XmlDocument xd = new XmlDocument();
jsonString = "{ \"myrootNode\": {" + jsonString.Trim().TrimStart('{').TrimEnd('}') + "} }";
xd = (XmlDocument)JsonConvert.DeserializeXmlNode(jsonString);
DataSet ds = new DataSet();
ds.ReadXml(new XmlNodeReader(xd));
return ds;
}
Happy Coding !!
No comments:
Post a Comment