Java 来自JsonArray的JsonArray
要从此链接提取数据吗- 这是我提取标题和作者的代码,但我可以获取标题,但不能获取作者Java 来自JsonArray的JsonArray,java,android,arrays,json,json-api,Java,Android,Arrays,Json,Json Api,要从此链接提取数据吗- 这是我提取标题和作者的代码,但我可以获取标题,但不能获取作者 JSONObject root = new JSONObject(bookJSON); JSONArray bookArray = root.getJSONArray("items"); String autho = " "; for (int i = 0; i < bookArray.length(); i++) { JSONObject currentBook = bookArray.
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);
}
}
JSONObject root=newjsonobject(bookJSON);
JSONArray bookArray=root.getJSONArray(“items”);
字符串autho=“”;
对于(int i=0;iauth.length();j++){
autho=auth.getString(j);
Log.i(“authorname”,autho);
}
}
JSONArray auth=volumeInfo.getJSONArray(“作者”);
int len=auth.length();
对于(int j=0;j
您需要获取
JSONArray
的每个索引元素,然后将其转换为String
您的问题到底是什么?谢谢@Devendra,但屏幕上显示的括号中的作者名称如下[Greg nudelman]我想删除括号,不显示作者名称Done。我已经更新了代码。请看一看@mohammedragabmohammedborik
JSONArray auth = volumeInfo.getJSONArray("authors");
int len = auth.length();
for (int j = 0; j < len; j++) {
autho = auth.get(j).toString();
Log.i("authorname",autho);
}