-------时刻谨记,JavaScript的优点是可以帮你做任何事,恰恰它的确定也是你依赖JavaScript做任何事
Dictionary<object, object> list = new Dictionary<object, object>();
DataTable dt = new DataTable();
JsonConvert.SerializeObject(list);
//----------此处JsonConvert.SerializeObject(list)仅为dataRows,并不是dataTable------
修改如下:
foreach (var key in dic.Keys){
dt.Columns.Add(key, typeof(string));
}
DataRow row = dt.NewRow();
foreach (Dictionary<string, string> item in dic) {
dr[item.Key] = item.Value;
}
dt.Rows.Add(dr);
return dt;
//------------此处返回的即为dataTable数据---------------- 新手小黑的笔记