{
"errNum": 0,
"errMsg": "success",
"retData": {
"from": "en",
"to": "zh",
"dict_result": {
"word_name": "hello",
"symbols": [
{
"ph_am": "hɛˈlo, hə-",
"ph_en": "hə'ləʊ",
"parts": [
{
"part": "int.",
"means": [
"哈喽,喂",
"你好,您好",
"表示问候",
"打招呼"
]
},
{
"part": "n.",
"means": [
"“喂”的招呼声或问候声"
]
},
{
"part": "vi.",
"means": [
"喊“喂”"
]
}
]
}
]
}
}
}
我想把里面的那些解释的意思(means)提取出来,无奈是新手弄了半天没弄出来 请各位帮帮忙
建立好类后序列化就好了。。代码如下
public class Parts { public System.Collections.Generic.List<string> means; }
public class Symbols { public System.Collections.Generic.List<Parts> parts; }
public class Dict_result { public System.Collections.Generic.List<Symbols> symbols;}
public class RetData { public Dict_result dict_result;}
public class Json { public RetData retData; }
protected void Page_Load(object sender, EventArgs e)
{
string d = System.IO.File.ReadAllText(Server.MapPath("bb.txt"), Encoding.UTF8);//这里改为你获取到的字符串,测试将你的内容放入文件里面进行读取
Json o = Newtonsoft.Json.JsonConvert.DeserializeObject(d, typeof(Json)) as Json;
foreach(Symbols symbol in o.retData.dict_result.symbols)
foreach(Parts part in symbol.parts)
foreach (string s in part.means) {
Response.Write(s + "<br>");
}
}
不好意思再请教一下如果要把part也解析出来,那么在建类的时候应该怎么建呢?