我正在使用Google Books API创建一个非常基本的图书搜索应用。我已完成所有工作以提取并显示JSON解析的信息,但是,如果键入“举重”之类的内容,则不会返回很多结果。看起来它只是在搜索标题。下面是我提取信息的代码。有谁知道要搜索关键字的摘要或列表或返回更多结果需要做些什么?当我运行搜索时,查询看起来像这样的“ https://www.googleapis.com/books/v1/volumes?q=video+game+development&maxResults=25”
任何帮助将不胜感激。谢谢!
List<Book> books = new ArrayList<>();
try {
JSONObject jsonBookObject = new JSONObject(bookJSON);
JSONArray bookArray = jsonBookObject.getJSONArray("items");
for (int i = 0; i < bookArray.length(); i++) {
JSONObject currentBook = bookArray.getJSONObject(i);
JSONObject volumeInfo = currentBook.getJSONObject("volumeInfo");
String title = volumeInfo.getString("title");
String authors = volumeInfo.getString("authors");
String date = volumeInfo.getString("publishedDate");
String url = volumeInfo.getString("infoLink");
books.add(new Book(title, authors, date, url));
Log.v(LOG_TAG, "JSON data successfully parsed");
}
} catch (JSONException e) {
// If an error is thrown when executing any of the above statements in the "try" block,
// catch the exception here, so the app doesn't crash. Print a log message
// with the message from the exception.
Log.e(LOG_TAG, "Problem parsing the earthquake JSON results", e);
}
return books;
}