Francisco Francisco - 5 months ago 54
reST (reStructuredText) Question

Service REST format JSON Wordpress

I need help to solve a problem. I´m using Wordpress APIRest to get JSON from my page.

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"));


This function give me the JSON with this format:

"rendered": "TITLE POST"

The problem is that i only want to get the title but the JSON let me the label "rendered" too. When I print it on my textfield it is: rendered: TITLE POST

Any help? Thanks


Get the "title" as follows,

String title = object.getJSONObject("title").getString("rendered");