title: Getting error about json and i am new in Android World
body: <p>I m getting this error when i click a button in Activity
  i m developing a Application in Android studio and getting error about json and  i m  not sure how to handle this error  </p>
  
  <p><strong>Error Detail</strong>    </p>
  
  <blockquote>
    <p>Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a 
    null object reference at com.example.tourista.DataParser.getAllnearbyPlaces(DataParser.java:62)
       at com.example.tourista.DataParser.parse(DataParser.java:100)</p>
  </blockquote>
  
  <pre><code>private List&lt;HashMap&lt;String,String&gt;&gt; getAllnearbyPlaces (JSONArray jsonArray)
  {
  
  //Line There i m getting Error
  
      int counter = jsonArray.length();
  
      List&lt;HashMap&lt;String,String&gt;&gt; NearbyPlacesList = new ArrayList&lt;&gt;();
      HashMap&lt;String,String&gt; NearbyplaceMap = null;
  
      if (jsonArray != null) {
  
          for (int i = 0; i &lt; counter; i++) {
              try {
                  NearbyplaceMap = getSingleNearbyPlace((JSONObject) jsonArray.get(i));
                  NearbyPlacesList.add(NearbyplaceMap);
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
          }
      }
      return NearbyPlacesList;
  }
  
  public List&lt;HashMap&lt;String,String&gt;&gt;  parse(String JSONdata)
  {
      JSONArray jsonArray= null;
      JSONObject jsonObject;
  
  
      try
      {
          jsonObject =new JSONObject(JSONdata);
          jsonArray = jsonObject.getJSONArray("results");
      }
      catch (JSONException e)
      {
          e.printStackTrace();
      }
      return getAllnearbyPlaces(jsonArray);
  
  }
  </code></pre>