}
或者
public static DataTable ToDataTable(string json)
{
DataTable dt = new DataTable();
DataTable result;
try
{
JavaScriptSerializer jz = new JavaScriptSerializer();
jz.MaxJsonLength = Int32.MaxValue;
ArrayList arraylist = jz.Deserialize
if (arraylist.Count > 0)
{
foreach (Dictionary
{
if (item.Keys.Count
{
result = dt;
return result;
}
if (dt.Columns.Count == 0)
{
foreach (string current in item.Keys)
{
dt.Columns.Add(current, item[current].GetType());
}
}
DataRow dataRow = dt.NewRow();
foreach (string current in item.Keys)
{
dataRow[current] = item[current];
}
dt.Rows.Add(dataRow); //循环添加行到DataTable中
}
}
}
catch (Exception)
{
throw;
}
result = dt;
return result;
}