首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

求json反序列化字符串,该怎么解决

2013-04-12 
求json反序列化字符串如题字符串值如下{1:{imgId:6554285643492469812,examplesEn:What usually

求json反序列化字符串
如题
字符串值如下
{"1":{"imgId":"6554285643492469812","examplesEn":"What usually happens is that people wait until they are really \nfed up, and then they blow their stack.","trans":"感到厌烦的;忍无可忍\n","des":"{id:504,create_time:"2013-04-01 15:19:32",remark:"",share:"",phonogram:"[fed][?p]",Examples_en:"What usually happens is that people wait until they are really <br \/>fed up, and then they blow their stack.",Examples_zh:"通常人们会等到实在无法忍受才会爆发。",annotation:"感到厌烦的;忍无可忍<br \/>",ori_img_id:8571294699692216353}","examplesZh":"通常人们会等到实在无法忍受才会爆发。","oriImgId":"8571294699692216353","pron":"[fed][?p]","word":"fed up","date":"2013-04-03"},"2":{"imgId":"2323423364183022435","examplesEn":"Grads need to take important factors into account \nwhen looking for a job. One of these factors is \nthe location of their future employers.","trans":"n. 位置(形容词locational);地点;外景拍摄场地\n","des":"{id:503,create_time:"2013-04-01 14:38:01",remark:"",share:"",phonogram:"[l?(?)'ke??(?)n]",Examples_en:"Grads need to take important factors into account <br \/>when looking for a job. One of these factors is <br \/>the location of their future employers.",Examples_zh:"毕业生找工作时,往往需要考虑诸多重要因素,其中之一便是工作地点。",annotation:"n. 位置(形容词locational);地点;外景拍摄场地<br \/>",ori_img_id:-9116571441237321213}","examplesZh":"毕业生找工作时,往往需要考虑诸多重要因素,其中之一便是工作地点。","oriImgId":"-9116571441237321213","pron":"[l?(?)'ke??(?)n]","word":"location","date":"2013-04-02"}

这是其中前2个,可能后边还会有第三个"3"
请问如何反序列化得到键值或者直接得到值也可以
如 imgId 6554285643492469812
或       6554285643492469812

直接上码的大大最给力了
[解决办法]

 json = json.Trim();
        if (json[0] != '[')
            json = "[" + json;
        if (json[json.Length - 1] != ']')
            json = json + "]";

        JavaScriptSerializer jss = new JavaScriptSerializer();
        ArrayList arrList = jss.Deserialize<ArrayList>(json);
        if (arrList.Count > 0)
        {
            foreach (Dictionary<string, object> arr in arrList)
            {
                  foreach (string key in arr.Keys)
                  {
                            //key就是属性
                                 //arr[key]就是对应的属性值


                  }
            }
        }

热点排行