json多层数组反序列化。解决思路

json多层数组反序列化。
{""Code"":1,""Message"":
[{""merchant_id"":8,""items"":[{""count"":2,""goods_name"":""商品1  汉堡包22222"",""goods_des"":""汉堡包的描述  有什么好描述的"",""goods_type"":1,""price"":19.80,""remark"":""20元起送"",""send_range"":""周边一公里"",""goods_id"":2,""create_time"":""2014-11-30 13:24:00"",""update_time"":""2014-11-30 13:24:00"",""status"":1,""user_name"":""test123""},
{""count"":2,""goods_name"":""商品1  汉堡包"",""goods_des"":""汉堡包的描述  有什么好描述的"",""goods_type"":1,""price"":19.80,""remark"":""20元起送"",""send_range"":""周边一公里"",""goods_id"":1,""create_time"":""2014-11-30 13:24:43"",""update_time"":""2014-11-30 13:24:43"",""status"":1,""user_name"":""test123""}
]}]}

------解决思路----------------------

using Newtonsoft.Json;
string jsonstr="{\"Code\":1,\"Message\":[{\"merchant_id\":8,\"items\":[{\"count\":2,\"goods_name\":\"商品1  汉堡包22222\",\"goods_des\":\"汉堡包的描述  有什么好描述的\",\"goods_type\":1,\"price\":19.80,\"remark\":\"20元起送\",\"send_range\":\"周边一公里\",\"goods_id\":2,\"create_time\":\"2014-11-30 13:24:00\",\"update_time\":\"2014-11-30 13:24:00\",\"status\":1,\"user_name\":\"test123\"},{\"count\":2,\"goods_name\":\"商品1  汉堡包\",\"goods_des\":\"汉堡包的描述  有什么好描述的\",\"goods_type\":1,\"price\":19.80,\"remark\":\"20元起送\",\"send_range\":\"周边一公里\",\"goods_id\":1,\"create_time\":\"2014-11-30 13:24:43\",\"update_time\":\"2014-11-30 13:24:43\",\"status\":1,\"user_name\":\"test123\"}]}]}";
           JObject jo = (JObject)JsonConvert.DeserializeObject(jsonstr);           
           string j1 = jo["Code"].ToString();
           JArray jarry = JArray.Parse(jo["Message"].ToString());
           for (var i = 0; i < jarry.Count; i++)
           {
               JObject j = JObject.Parse(jarry[i].ToString());
               MessageBox.Show(j["merchant_id"].ToString());
               JArray jarry1 = JArray.Parse(j["items"].ToString());
               for (var k = 0; k < jarry1.Count; k++)
               {
                   JObject jk = JObject.Parse(jarry1[k].ToString());
                   MessageBox.Show(jk["goods_name"].ToString());
                   MessageBox.Show(jk["remark"].ToString());
               }
           }



------解决思路----------------------
1.后台要定义一个类型用于接收json,数据结构同json;
2.用Newtonsoft反序列化。

例如:
  Dictionary<string, ClassInfo> aa = new Dictionary<string, ClassInfo>();
            
            ClassInfo c1 = new ClassInfo() {Name = "班级1", Cnt = 42};
            ClassInfo c2 = new ClassInfo() {Name = "班级2", Cnt = 45};

            aa.Add("001", c1);
            aa.Add("002", c2);

            string bb = JsonConvert.SerializeObject(aa);

            var cc = JsonConvert.DeserializeObject<Dictionary<string, ClassInfo>>(bb);

            var dd = cc["002"];
            var dd1 = dd.Name;
            var dd2 = dd.Cnt;