如题
字符串值如下
{"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\",re:\"\",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\",re:\"\",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直接上码的大大最给力了
字符串值如下
{"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\",re:\"\",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\",re:\"\",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直接上码的大大最给力了
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]就是对应的属性值
}
}
}
foreach (KeyValuePair<string, fastCSharp.setup.cSharp.ajax.jsonNode> node in jsonNode.Dictionary)
{
Console.WriteLine(node.Key);
Console.WriteLine(fastCSharp.setup.cSharp.ajax.parseJson.Get<string>(node.Value.Dictionary["imgId"]));
}
这样会解析你的json串,使用的时候是obj.imgid类似
我用winform做的,BS的能看懂一点但写不出来