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