You just use the below method
public string GetJson(DataSet ds)
{
System.Web.Script.Serialization.JavaScriptSerializer serializer = new
System.Web.Script.Serialization.JavaScriptSerializer();
List> rows =
new List>();
Dictionary row = null;
foreach (DataRow dr in ds.Tables[0].Rows)
{
row = new Dictionary();
foreach (DataColumn col in ds.Tables[0].Columns)
{
row.Add(col.ColumnName.Trim(), dr[col]);
}
rows.Add(row);
}
return serializer.Serialize(rows);
}