【发布时间】:2020-08-08 12:58:58
【问题描述】:
我想从这个 JSON 中提取作者,我成功获得了JSONArray,但我不知道如何将其转换为String[],我必须将这个String[] 传递给一个方法。请尽量保持解决方案简单,因为我只是一个初学者。
JSON:
{
"volumeInfo": {
"title": "Android",
"authors": [
"P.K. Dixit"
]
}
}
代码:
JSONObject volumeInfo = currentBook.getJSONObject("volumeInfo");
// Extract the value for the key called "title"
String title = volumeInfo.optString("title");
// Extract the array for the key called "authors"
JSONArray authors = volumeInfo.optJSONArray("authors");
【问题讨论】:
-
您使用哪个库进行 JSON 处理?
-
这能回答你的问题吗? Convert JSONArray to String Array