public string GetJson(DataTable dt){
JavaScriptSerializer jss=new JavaScriptSerializer();
jss.MaxJsonLength=Int32.MaxValue;
System.Collections.Arraylist dic=new System.Collections.ArrayList();
foreach(DataRow dr in dt.Rows){
System.Collections.Generic.Dictionary<string,string> drow=new System.Collections.Generic.Dictionary<string,string>();
foreach(DataColumn dc in dt.Columns){
drow.Add(dc.ColumnName,dr[dc.ColumnName]);
}
dic.Add(drow);
}
return jss.Serialize(dic);
}
时间: 2024-10-09 22:33:28