string 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"}
在JS中:假设你的json 对象是 jObject
var picArr = jObject['taobao_pic_urls']
获取其中的某项值
var index = 0//要获取的下标
var picUrl = picArr[index]
在java中:
可以使用net.sf.JsonObject 和 net.sf.JsonArray
假设你的json 对象是 jObject net.sf.JsonObject对象格式
获取数组
JosnArray jArray = jObject.getJSONArray("taobao_pic_urls")
获取其中的某项值
int index = 0//要获取的下标
String picUrl = String.valueOf(jArray.get(index))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)