Newtonsoft.Json 4.5.11

 static void Main(string[] args)
        {
            string jsonText = "[{\"a\":\"aaa\",\"b\":\"bbb\",\"c\":\"ccc\"},{\"a\":\"aaa2\",\"b\":\"bbb2\",\"c\":\"ccc2\"}]";
            //JArray ja = (JArray)JsonConvert.DeserializeObject(jsonText);
            //JObject o = (JObject)ja[1];
            //Console.WriteLine(o["a"]);//aaa2
            //Console.WriteLine(ja[1]["a"]);//aaa2

            List _list = JsonConvert.DeserializeObject>(jsonText);
            Console.WriteLine(_list[1].a);//aaa2

            foreach (Customer c in _list)
            {
                Console.WriteLine(c.c);
            }
            Console.ReadLine();

        }
 public class Customer
    {
        //在序列化前后没有变动  
        public string a { get; set; }
        //在序列化前后设置和重置  
        public string b { get; set; }
        //设置为null,但在序列化后填充  
        public string c { get; set; }
        public string Other { get; set; }
        public Customer()
        {
            //  
            //TODO: 在此处添加构造函数逻辑  
            //  
            a = "";
            b = "";
            c = "";
            Other = null;
        }
    }


你可能感兴趣的:(C#)