Newtonsoft.Json:JObject 动态添加字段/List<JObject>转DataTable
1.JObject 动态添加字段;
var jsonObject = new JObject(); foreach (var key in Keys) { jsonObject.Add(key, value); } jsonObject.Add("*****", "1");
2. List<JObject>转DataTable
1): 首先List<JObject>转string
List<JObject> jsons = new List<JObject>();
...
string jsonStr = JsonConvert.SerializeObject(jsons);
2): string转DataTable
DataTable table1 = JsonConvert.DeserializeObject<DataTable>(jsonStr);