Francisco Francisco - 1 year ago 102
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

Answer Source

Get the "title" as follows,

String title = object.getJSONObject("title").getString("rendered");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download