【发布时间】:2017-10-04 10:38:12
【问题描述】:
想要从此链接中提取数据 - https://www.googleapis.com/books/v1/volumes?q=android&maxResults=16
这是我提取标题和作者的代码,但我可以获取标题但不能获取作者。
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);
}
}
【问题讨论】:
-
你的问题到底是什么?
标签: java android arrays json json-api