JSON Parsing NullPointerException in android
<p>I am learning JSON parsing in android. My logcat is showing  NullPointerException onpostexecute method. I have shared the code below.</p>

<pre><code>    protected String doInBackground(String... urls) 
{

    // TODO Auto-generated method stub
    try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url1);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();           

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    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();
    } catch (Exception e) {
        Log.e("Buffer Error", "Error converting result " + e.toString());
    }

   return result;

}
 protected void onPostExecute(String result) {
      // try parse the string to a JSON object
        try {
            jObj = new JSONObject(result);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        }

    }
      public JSONObject getJSONFromUrl()
    { 
  return jObj;
     }
</code></pre>

<p>JSONParser object in Main Activity </p>

<pre><code>JSONParser jParser = (JSONParser) new JSONParser().execute(url);
    try
    {
        Thread.sleep(2000);

    }
    catch (InterruptedException e)
    {
        // TODO: handle exception
        e.printStackTrace();
    }

    // getting JSON string from URL
    JSONObject json = jParser.getJSONFromUrl();
</code></pre>

<p>I can't figure out the problem. provide suggestions....</p>
