我需要帮助才能解决问题。我正在使用Wordpress APIRest从我的页面获取JSON。
@Override
public void onFeed(JSONArray array) {
posts=new ArrayList<>();
int length=array.length();
for(int i=0; i<length;i++){
JSONObject object= array.optJSONObject(i);
Spanned desc= Html.fromHtml(object.optString("excerpt"));
//Spanned tit=Html.fromHtml(object.optString("title"));
Post post=new Post(object.optString("title"), desc.toString(),object.optString("featured_image"));
posts.add(post);
}
postAdapter.addAll(posts);
postAdapter.notifyDataSetChanged();
}
这个函数给我这个格式的JSON:
"title":
{
"rendered": "TITLE POST"
},
问题是我只想获得标题,但JSON让我的标签“渲染”了。当我在我的文本字段上打印时,它是:呈现:TITLE POST
有任何帮助吗?感谢
答案 0 :(得分:0)
获取如下“标题”,
String title = object.getJSONObject("title").getString("rendered");