2、检查编码是否统一。
3、json的包有没导错。排除了,就是函数调用的问题了- -!看样子传入的是array数据,应该用jsonArray解析。JSONArray jsonArray = new JSONArray(jsonContent.toString())然后可以逐一读取里面的数据:JSONObject itemObj = jsonArray.getJSONObject(i)。
安装Json.net,using Newtonsoft.Json.Linqstring result = string.Empty
using (StreamReader sr = new StreamReader(File.Open(@"D:\csharp\output\output\data.json", FileMode.Open)))
{
result = sr.ReadToEnd()
}
JObject jo = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result)
Console.WriteLine(jo["data"]["symbols"][0]["parts"][0]["means"][1].ToString())
Console.ReadLine()
data.json就是存放的
{"errno":0,"data":{"word_name":"\u597d","symbols":[{"ph_zh":"h\u01ceo","parts":[{"part":"\u5f62","means":["good","fine","nice"]}]},{"ph_zh":"h\u00e0o","parts":[{"part":"\u52a8","means":["like","love","be fond of"]},{"part":"\u540d","means":["a surname"]}]}]},"to":"en","from":"zh"}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)