博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

json格式字符串处理

Posted on 2014-08-12 18:23  米粒3  阅读(153)  评论(0编辑  收藏  举报
public class InternalClass
        {
            public int MID;
            public string Name;
            public string Des;
            public string Disable;
            public string Remark;
        }
 
        public class OuterClass
        {
            public bool phantom;
            public string id;
 
            public InternalClass data;
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            const string json = @"{""phantom"":true,
                                   ""id"":""ext-record-10"",
                                   ""data"":
                                  {""MID"":1019,
                                   ""Name"":""aaccccc"",
                                    ""Des"":""cc"",
                                    ""Disable"":""启用"",
                                    ""Remark"":""cccc""}}";
            JavaScriptSerializer ser = new JavaScriptSerializer();
            OuterClass foo = ser.Deserialize<OuterClass>(json); 
 
 
        }
 
 
JavaScriptSerializer类 需要引用System.Web.Extensions