{
"sm_api_character_count": "1284",
"sm_api_content_reduced": "64%",
"sm_api_title": "‘Schoolhouse Rock\\'",
"sm_api_content": " Musician Bob Dorough, 94, best known as a
composer
and performer for ABC's educational series of short cartoons
Schoolhouse Rock!, died of natural causes at his Mount Bethel,
Pa., home on Monday, his son, Chris, said. Mc Call asked Mr.
Dorough to put the multiplication tables to music, leading to
\"Three Is a Magic Number,\" as well as a Multiplication Rock
collection.",
"sm_api_limitation": "Waited 0 extra seconds due to API Free mode,
97 requests left to make for today."
}
我正在使用名为smmry的API,而我正在尝试解析" sm_api_content" JSON对象,用于获取链接文章的摘要。但是,我很难这样做。根据smmry,这些对象被包装在JSON数组中,但我不知道这个数组被调用了什么(因为截图中没有方括号来表示数组)。
try {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
Request.Method.GET,
"https://api.smmry.com/&SM_API_KEY="
+ API_KEY + "&SM_URL=" + "https://www.studentnewsdaily.com/daily-news-article/schoolhouse-rock/",
null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(final JSONObject response) {
try {
Log.d(TAG, response.toString(2));
} catch (JSONException ignored) { }
try {
String theSummary = response
.getJSONObject("sm_api_content")
.toString();
TextView getSummary = findViewById(R.id.getSummary);
getSummary.setText(theSummary);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(final VolleyError error) {
Log.e(TAG, error.toString());
}
});
requestQueue.add(jsonObjectRequest);
} catch (Exception e) {
e.printStackTrace();
}
这就是我目前正在做的事情,但显然它不起作用。任何指导或帮助将不胜感激!谢谢!