Google APIを使用したアプリケーションを作成していますが、Googleブックスに関する詳細が取得されています。JSONでのパスの検索コード
次のJSONリンクから、著者と書籍のタイトルに関するデータを取得したいと考えています。
https://www.googleapis.com/books/v1/volumes?q=android
問題への私のアプローチ:
private Book extractFeatureFromJson(String bookJSON) {
try {
JSONObject baseJsonResponse = new JSONObject(bookJSON);
JSONArray items = baseJsonResponse.getJSONArray("items");
// If there are results in the features array
for(int i=0;i<10;i++)
{
JSONObject firstFeature = items.getJSONObject(i);
JSONObject volumeinfo=firstFeature.getJSONObject("volumeinfo");
String title=volumeinfo.getString("title");
JSONArray author= volumeinfo.getJSONArray("authors");
for(int j=0;j<author.length();j++)
{
JSONObject authorFeature=author.getJSONObject(j);
}
// Create a new {@link Event} object
return new Book(title,author);
}
} catch (JSONException e) {
Log.e(LOG_TAG, "Problem parsing the earthquake JSON results", e);
}
return null;
}
パスへの私のアプローチは間違っていると間違いがある場合、私はそれを把握することはできません。
JSONレスポンスを挿入できますか? –
ここはhttps://www.googleapis.com/books/v1/volumes?q=androidです。 –
'author.getJSONObject(j);'あなたは 'authors'の内容がオブジェクトだと思いますか? – njzk2