Newtonsoft.Json
C# JsonConvert时间格式问题
var format = new IsoDateTimeConverter(); format.DateTimeFormat = "yyyy-MM-dd hh:mm:ss"; string param = JsonConvert.SerializeObject(data, format);
C# Newtonsoft.Json不序列字段
[JsonObject(MemberSerialization.OptOut)] public class employeePersonalForm { [JsonIgnore] public string id { get; set; } }
{ "Category": { "Better": [ 99, 98, 100, 96 ], "Normal": [ 80, 75, 84 ] } }
提取数组:
Newtonsoft.Json.Linq.JObject obj
= (JObject)JsonConvert.DeserializeObject(jsonText);
var arr = obj["Category"]["Better"] as JArray;
Newtonsoft.Json.Linq.JToken tobj = obj.First;
var Path = tobj.Path; //Category
var arr = obj[Path].First as JArray;
var Name= obj.Name; //Category