title: Json Array returning null while parsing in Android
body: <p>I know this is a very commonly asked question and I found quite a lotta posts in SO. 
  My code is as below and I don't see a reason why the json array is returning null. Could someone please review it for me please? I've left no stones left unturned! :( </p>
  
  <pre><code>JsonArray jsonArr = JSONfunctions.getJSONfromURL(url);
      try {
          if (jsonArr != null) {
              for (int i = 0; i &lt; jsonArr.length(); i++) {
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  JSONObject jsonObj = jsonArr.getJSONObject(i);
  
                  map.put(TAG_CODE, jsonObj.getString("Code"));
                  map.put(TAG_DISPLAY_NAME, jsonObj.getString("UserName"));
                  map.put(TAG_PROGRAM_NAME, jsonObj.getString("Password"));
                  mylist.add(map);
              }
          }
      } catch (JSONException e) {
          Log.e("log_tag", "Error parsing data " + e.toString());
      }                                                                                      
  
  
  
  
  
  
  public class JSONfunctions {
  
  public static JSONArray getJSONfromURL(String url) {
      InputStream is = null;
      String result = "";
      JSONArray jArray = null;
  
      // http post
      try {
  
          HttpClient httpclient = new DefaultHttpClient();
          HttpGet httppost = new HttpGet(url);
          // httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
          HttpResponse response = httpclient.execute(httppost);
          HttpEntity entity = response.getEntity();
          is = entity.getContent();
  
      } catch (Exception e) {
          Log.e("log_tag", "Error in http connection " + e.toString());
      }
  
      // convert response to string
      try {
          BufferedReader reader = new BufferedReader(new InputStreamReader(
                  is, "iso-8859-1"), 8);
          StringBuilder sb = new StringBuilder();
          String line = null;
          while ((line = reader.readLine()) != null) {
              sb.append(line + "\n");
          }
          is.close();
          result = sb.toString();
  
                  // Result is always returning me an array.(not null)
  
      } catch (Exception e) {
          Log.e("log_tag", "Error converting result " + result);
      }
      try {
          jArray = new JSONArray(result);
  
                  // Goes into the catch block
  
      } catch (JSONException e) {
          // TODO Auto-generated catch block
          Log.e("log_tag", "Error parsing result " + result);
      }
      return jArray;
  
  }
  </code></pre>
  
  <p>}</p>