public static string GetJsonString(DataSet ds)
{
string json = "";
IList<Hashtable> mList = new List<Hashtable>();
try
{
foreach (DataRow row in ds.Tables[0].Rows)
{
Hashtable ht = new Hashtable();
foreach (DataColumn col in ds.Tables[0].Columns)
{
ht.Add(col.ColumnName, row[col.ColumnName]);
}
mList.Add(ht);
}
json = JsonConvert.SerializeObject(mList);
}
catch (Exception ee)
{
string error = ee.Message;
}
return json;
}
{
string json = "";
IList<Hashtable> mList = new List<Hashtable>();
try
{
foreach (DataRow row in ds.Tables[0].Rows)
{
Hashtable ht = new Hashtable();
foreach (DataColumn col in ds.Tables[0].Columns)
{
ht.Add(col.ColumnName, row[col.ColumnName]);
}
mList.Add(ht);
}
json = JsonConvert.SerializeObject(mList);
}
catch (Exception ee)
{
string error = ee.Message;
}
return json;
}