想從這個鏈接中提取數據 - https://www.googleapis.com/books/v1/volumes?q=android&maxResults=16JsonArray從JsonArray
這是我的代碼中提取標題和作者,但我能拿到冠軍,但不是作者。
JSONObject root = new JSONObject(bookJSON);
JSONArray bookArray = root.getJSONArray("items");
String autho = " ";
for (int i = 0; i < bookArray.length(); i++) {
JSONObject currentBook = bookArray.getJSONObject(i);
JSONObject volumeInfo = currentBook.getJSONObject("volumeInfo");
String title = volumeInfo.getString("title");
Log.i("booktitle",title);
JSONArray auth = volumeInfo.getJSONArray("authors");
for (int j = 0; j > auth.length(); j++) {
autho = auth.getString(j);
Log.i("authorname",autho);
}
}
什麼是你的問題? – megalucio