Это ответ JSON, который будет получен от OkHTTP.Это только одна часть ответа из 10 частей ответа.
[{"id":418,"title":{"rendered":"testttt"},"content":{"rendered":"
\n\nThis is a random post trying to implement some feature soon and we
don\u2019t have any option rather than try in the production environment only.
Just because this is a stupid decision don\u2019t blame me for this,
please.\n\n<\/p>\n","protected":false}]
Это код, который я пытаюсь получить для заголовка> отображается ниже:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://url.com/wp-json/wp/v2/posts")
.build();
Response response = client.newCall(request).execute();
String myResponse = response.body().string();
JSONObject json = new JSONObject(myResponse);
for(int i=0; i <=9 ; i++){
JSONArray jsonArray = json.getJSONArray("title");
String title = jsonArray.getString("rendered");
titles.add(title);
}
Но я получаю это error: incompatible types: String cannot be converted to int
.
Я не знаю, где я не прав.