#region Json转DataTable

#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

上一篇:LSTM实现中文文本情感分析


下一篇:SpringMVC+Spring+Hibernate的小样例