using Newtonsoft.Json;
List<DataColumnModel> lstColumn = new List<DataColumnModel>()
{
new DataColumnModel { ColumnName = "Name", ColumnCaption = "部门名称", ColumnType = typeof(string) },
new DataColumnModel { ColumnName = "Value", ColumnCaption = "小计", ColumnType = typeof(int) }
};
string json = JsonConvert.SerializeObject(data.rows);
JArray jArray = (JArray)JsonConvert.DeserializeObject(json);
JToken jObj = (JToken)jArray[0];
foreach (JProperty jp in jObj)
{
string name = jp.Name;
if (name != "Name" && name != "OrgId" && name != "Value")
{
DataColumnModel col = new DataColumnModel();
col.ColumnName = name;
col.ColumnCaption = name;
col.ColumnType = typeof(int);
lstColumn.Add(col);
}
}