我試圖解析此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