标签:
#region Json转DataTable
private DataTable Json2Dtb(string json)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
ArrayList dic = jss.Deserialize<ArrayList>(json);
DataTable dtb = new DataTable();
if (dic.Count > 0)
{
foreach (Dictionary<string, object> drow in dic)
{
if (dtb.Columns.Count == 0)
{
foreach (string key in drow.Keys)
{
dtb.Columns.Add(key, drow[key].GetType());
}
}
DataRow row = dtb.NewRow();
foreach (string key in drow.Keys)
{ row[key] = drow[key]; }
dtb.Rows.Add(row);
}
}
return dtb;
}
#endregion
标签:
原文地址:http://www.cnblogs.com/lijinzhu7929/p/5664678.html