everytime i run my code i get the error. "JSON.typeMismatch(JSON.java:111)". how can I parse a JSON object wrapped with an array? here is my code : > package com.communications.dell.pullbw;
> 
> import android.content.Context; import android.os.AsyncTask; import
> android.support.v7.app.AppCompatActivity; import android.os.Bundle;
> import android.view.LayoutInflater; import android.view.View; import
> android.view.ViewGroup; import android.widget.ArrayAdapter; import
> android.widget.ListView; import android.widget.TextView;
> 
> import com.squareup.okhttp.OkHttpClient; import
> com.squareup.okhttp.Request; import com.squareup.okhttp.Response;
> 
> import org.json.JSONArray; import org.json.JSONException; import
> org.json.JSONObject;
> 
> import java.io.IOException; import java.util.ArrayList;
> 
> public class FeedActivity extends AppCompatActivity implements
> OnFeedListener {
> 
>     ListView listView;
>     FeedAdapter adapter;
>     ArrayList<Post> posts;
> 
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.activity_feed);
> 
>         listView = (ListView)findViewById(R.id.listView);
> 
>         adapter= new FeedAdapter(getApplicationContext(), R.layout.layout_feed_item);
> 
>         listView.setAdapter(adapter);
> 
>         FeedTask task= new FeedTask(this);
> 
>         task.execute("http://www.botswanayouth.com/wp-json/wp/v2/posts");
>     }
> 
>     @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);
> 
>             Post post = new Post(object.optString("title"),object.optString("excerpt"),object.optString("featured_media"));
> 
>             posts.add(post);
> 
>         }
>         adapter.addAll(posts);
> 
>     }
> 
>     public class FeedTask extends AsyncTask<String, Void, JSONArray>
>     {
>         private OnFeedListener listener;
>         public FeedTask(OnFeedListener listener)
>         {
>             this.listener= listener;
>         }
>         @Override
>         protected JSONArray doInBackground(String... params) {
> 
>             String url = params[0];
>             OkHttpClient client= new  OkHttpClient();
>             Request.Builder builder= new Request.Builder();
> 
>             Request request= builder.url(url).build();
> 
>             try {
>                 Response response= client.newCall(request).execute();
> 
>                 String json= response.body().string();
> 
>                 try
>                 {
>                     JSONObject object= new JSONObject(json);
>                     JSONArray array = object.optJSONArray("posts");
> 
>                     return array;
>                 }
>                 catch (JSONException e)
>                 {
>                     e.printStackTrace();
>                 }
> 
>             }
>             catch (IOException e)
>             {
>                 e.printStackTrace();
>             }
>             return null;
>         }
> 
>         @Override
>         protected void onPostExecute(JSONArray array) {
>             super.onPostExecute(array);
> 
>             if (null== array)
>                 return;
> 
>             if (null != listener)
>                 listener.onFeed(array);
>         }
>     }
> 
>     public class FeedAdapter extends ArrayAdapter<Post>
>     {
>         private int resource;
>         public FeedAdapter(Context context, int resource)
>         {
>             super(context, resource);
>             this.resource=resource;
>         }
> 
>         @Override
>         public View getView(int position, View convertView, ViewGroup parent) {
> 
>             if (null==convertView)
>             {
>                 LayoutInflater inflater=LayoutInflater.from(getContext());
>                 convertView=inflater.inflate(resource, null);
>             }
> 
>             Post post = getItem(position);
> 
>             TextView title = (TextView) convertView.findViewById(R.id.title);
>             TextView desc = (TextView) convertView.findViewById(R.id.description);
>             title.setText(post.title);
>             desc.setText(post.description);
> 
>             return convertView;
>         }
>     }
> 
>     public class Post{
>         public String title;
>         public String description;
>         public String thumbnail; //URL
> 
>         public Post(String title, String desc, String thumbnail)
>         {
>             this.title=title;
>             this.description=desc;
>             this.thumbnail=thumbnail;
>         }
>     }
> 
> 
> }

