我试图解析此JSON代码如何解析JSON结构化JSON数组对象在Java中
{
"resultCode":"350",
"message":"OK",
"result":1,
"data":
{
"totalCount":"2",
"videos":[
{
"videoId":"73bfedf534",
"VideoUrl":"www.videourlexample.com",
"title":"vbsample1",
"description":""
},
{
"videoId":"73bfedf534",
"VideoUrl":"www.videourlexample.com",
"title":"vbsample2",
"description":""
}
]
}
}
我能仅此解析。
"resultCode":"350",
"message":"OK",
"result":1,
这是Java代码
JSONObject jsonObject = (JSONObject)
//return the JSON code above.
jsonParser.parse(getHTML("...httpRequest..."));
// get a String from the JSON object
String resultCode = (String) jsonObject.get("resultCode");
System.out.println("[RESULTCODE] The message is: " + resultCode);
// get a String from the JSON object
String message = (String) jsonObject.get("message");
System.out.println("[MESSAGE] The message is: " + message);
// get a number from the JSON object
long result = (long) jsonObject.get("result");
System.out.println("[RESULT] The resultCode is: " + result);
我无法分析 “数据”。有人可以帮助我吗? 我想从json数组中分别获取每个值......比如resultCode,消息和结果。
谢谢。
可能重复(http://stackoverflow.com/questions/20899839/retreiving-values-from-nested-json-object) – PKuhn