日期:2014-05-16  浏览次数:21222 次

JSON 定义实体类,来个人解答一下吧。
示例: 
{
     "button":[
     {
          "type":"click",
          "name":"今日歌曲",
          "key":"V1001_TODAY_MUSIC"
      },
      {
           "type":"click",
           "name":"歌手简介",
           "key":"V1001_TODAY_SINGER"
      },
      {
           "name":"菜单",
           "sub_button":[
           {
               "type":"view",
               "name":"搜索",
               "url":"http://www.soso.com/"
            },
            {
               "type":"view",
               "name":"视频",
               "url":"http://v.qq.com/"
            },
            {
               "type":"click",
               "name":"赞一下我们",
               "key":"V1001_GOOD"
            }]
       }]
 }
我定义的实体类:
 [Serializable]
    public class Menu
    {
        public Button[] button;
        //public Sub_button[] sub_button;
    }

    [Serializable]
    public class Button
    {
        public string type = "click";
        public string name;
        public string key;
        public Sub_button[] sub_button;
     //   public List<Buttont> sub_button;
    //    public string url;
    }

    [Serializable]
    public class Sub_button
    {
        public string type = "view";
        public string name;