title: json data not parse from web
body: <p><strong>MainActivity.java</strong></p>
  
  <pre><code>import android.app.Activity;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.widget.ListView;
  import android.widget.Toast;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.util.EntityUtils;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.io.IOException;
  import java.util.ArrayList;
  
  public class MainActivity extends Activity {
  
  
      ListView list;
      ActorsAdapter adapter;
      ArrayList&lt;Actors&gt; actorslist;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
          list = (ListView)findViewById(R.id.list);
  
          adapter = new ActorsAdapter(getApplicationContext(), R.layout.list_category, actorslist);
  
          list.setAdapter(adapter);
          actorslist=new ArrayList&lt;Actors&gt;();
  
          new actorsAsyncTask().execute("http://paradiseitsolutions.co.in/app/sanvi/json/getcategory.php");
          }
  
      public class actorsAsyncTask extends AsyncTask&lt;String,Void,Boolean&gt;{
  
  
          @Override
          protected Boolean doInBackground(String... params) {
  
                  try {
                      HttpClient client= new DefaultHttpClient();
                      HttpPost post=new HttpPost(params[0]);
                      HttpResponse response= client.execute(post);
                      int status =response.getStatusLine().getStatusCode();
                      if(status==200){
                          HttpEntity entity=response.getEntity();
                          String data= EntityUtils.toString(entity);
  
  
                          JSONObject jobj= new JSONObject(data);
                          JSONArray jarray = jobj.getJSONArray("result");
  
                          for(int i =0;i&lt;jarray.length();i++){
  
                              Actors actor = new Actors();
                              JSONObject jrealObject = jarray.getJSONObject(i);
                              actor.setId(jrealObject.getString("id"));
                              actor.setName(jrealObject.getString("name"));
                              actor.setImage(jrealObject.getString("image"));
  
                              actorslist.add(actor);
                          }
                          return true;
                      }
              } catch (IOException e) {
                  e.printStackTrace();
              } catch (JSONException e) {
                      e.printStackTrace();
                  }
  
              return false;
          }
  
          @Override
          protected void onPostExecute(Boolean result) {
              super.onPostExecute(result);
  
              if(result== false)
              {
                  //data is not parse
                  Toast.makeText(getApplicationContext(), "this is my Toast message!!! =)",
                          Toast.LENGTH_LONG).show();
              }else {
                  ActorsAdapter adapter =new ActorsAdapter(getApplicationContext(),R.layout.list_category,actorslist);
                  list.setAdapter(adapter);
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>ActorsAdapter.java</strong></p>
  
  <pre><code>    import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.os.AsyncTask;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.io.InputStream;
  import java.util.ArrayList;
  
  /**
   * Created by paradise on 2/27/2016.
   */
  public class ActorsAdapter extends ArrayAdapter&lt;Actors&gt; {
  
  
  
      ArrayList&lt;Actors&gt; ArrayListActors;
      int Resource;
      Context context;
      LayoutInflater vi;
  
  
      public ActorsAdapter(Context context, int resource, ArrayList&lt;Actors&gt; objects) {
          super(context, resource, objects);
  
          ArrayListActors =objects;
          Resource=resource;
          this.context = context;
  
          vi=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          ViewHolder holder;
  
          if(convertView == null){
  
              convertView = vi.inflate(Resource,null);
              holder = new ViewHolder();
  
              holder.ivImage = (ImageView)convertView.findViewById(R.id.ivImage);
              holder.tvId = (TextView)convertView.findViewById(R.id.tvId);
              holder.tvName = (TextView)convertView.findViewById(R.id.tvName);
  
              convertView.setTag(holder);
          }else {
  
              holder = (ViewHolder)convertView.getTag();
          }
  
          new DownloadImageTask(holder.ivImage).execute();
          holder.tvId.setText("id =" + ArrayListActors.get(position).getId());
          holder.tvName.setText("name=" +ArrayListActors.get(position).getName());
  
          return convertView;
      }
  
  
  
      static class ViewHolder {
  
          public TextView tvId;
          public ImageView ivImage;
          public TextView tvName;
  
      }
  
      private class DownloadImageTask extends AsyncTask&lt;String, Void, Bitmap&gt; {
          ImageView bmImage;
  
          public DownloadImageTask(ImageView bmImage) {
              this.bmImage = bmImage;
          }
          protected Bitmap doInBackground(String... urls) {
              String urldisplay = urls[0];
              Bitmap mIcon = null;
              try {
                  InputStream in = new java.net.URL(urldisplay).openStream();
                  mIcon = BitmapFactory.decodeStream(in);
              } catch (Exception e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return mIcon;
          }
  
      }
  
  }
  </code></pre>
  
  <p><strong>Actors.java</strong></p>
  
  <pre><code>    public class Actors {
  
      private String id;
      private String name;
      private String image;
  
     //getters and setters
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getImage() {
          return image;
      }
  
      public void setImage(String image) {
          this.image = image;
      }
      //default constructor
      public Actors(){
  
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:padding="5dp"
      tools:context="com.example.paradise.pagalshayar.MainActivity"&gt;
  
      &lt;ListView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/list"
          tools:listitem="@layout/list_category"&gt;
  
      &lt;/ListView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>list_category.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:text="id"
          android:id="@+id/tvId"/&gt;
  
     &lt;ImageView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:id="@+id/ivImage"/&gt;
  
      &lt;TextView
          android:text="name"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/tvName"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <blockquote>
    <p>in my app 3 class and 2 xml file . but problem is that json is not parsing app has been crashed and gove error message is Fatel Exception:main</p>
  </blockquote>
  
  <p><strong>Error message</strong></p>
  
  <pre><code>02-27 13:57:16.197 19624-19624/com.example.paradise.pagalshayar E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.paradise.pagalshayar, PID: 19624
     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.paradise.pagalshayar/com.example.paradise.pagalshayar.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
      at android.app.ActivityThread.-wrap11(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
      at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:337)
      at android.widget.ListView.setAdapter(ListView.java:491)
      at com.example.paradise.pagalshayar.MainActivity.onCreate(MainActivity.java:40)
      at android.app.Activity.performCreate(Activity.java:6251)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>