【发布时间】:2021-10-20 22:39:53
【问题描述】:
the JSON data from the API I'm using
部分代码:我已经在代码中指出,但不知道该放什么: JSONObject volumeObj = itemsObj.getJSONObject("");在基于该 API 的“”中。我可以在代码中修改什么或放入“ ”以让我从 {0}、{1} 等获取对象?
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
// below line is use to make json object request inside that we
// are passing url, get method and getting json object. .
JsonObjectRequest booksObjrequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
progressBar.setVisibility(View.GONE);
// inside on response method we are extracting all our json data.
try {
JSONArray itemsArray = response.getJSONArray("result");
for (int i = 0; i < itemsArray.length(); i++) {
JSONObject itemsObj = itemsArray.getJSONObject(i);
**JSONObject volumeObj = itemsObj.getJSONObject("");**
String title = volumeObj.optString("title");
String subtitle = volumeObj.optString("subtitle");
JSONArray authorsArray = volumeObj.getJSONArray("authors");
String publisher = volumeObj.optString("publisher");
String publishedDate = volumeObj.optString("publishedDate");
String description = volumeObj.optString("description");
【问题讨论】:
标签: android arrays json api android-volley