title: Get a JSON object from a HTTP response
body: <p>I want to get a <code>JSON</code> object from a Http get response:</p>
  
  <p>Here is my current code for the Http get:</p>
  
  <pre><code>protected String doInBackground(String... params) {
  
      HttpClient client = new DefaultHttpClient();
      HttpGet request = new HttpGet(params[0]);
      HttpResponse response;
      String result = null;
      try {
          response = client.execute(request);         
          HttpEntity entity = response.getEntity();
  
          if (entity != null) {
  
              // A Simple JSON Response Read
              InputStream instream = entity.getContent();
              result = convertStreamToString(instream);
              // now you have the string representation of the HTML request
              System.out.println("RESPONSE: " + result);
              instream.close();
              if (response.getStatusLine().getStatusCode() == 200) {
                  netState.setLogginDone(true);
              }
  
          }
          // Headers
          org.apache.http.Header[] headers = response.getAllHeaders();
          for (int i = 0; i &lt; headers.length; i++) {
              System.out.println(headers[i]);
          }
      } catch (ClientProtocolException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      } catch (IOException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      }
      return result;
  }
  </code></pre>
  
  <p>Here is the convertSteamToString function:</p>
  
  <pre><code>private static String convertStreamToString(InputStream is) {
  
      BufferedReader reader = new BufferedReader(new InputStreamReader(is));
      StringBuilder sb = new StringBuilder();
  
      String line = null;
      try {
          while ((line = reader.readLine()) != null) {
              sb.append(line + "\n");
          }
      } catch (IOException e) {
          e.printStackTrace();
      } finally {
          try {
              is.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      return sb.toString();
  }
  </code></pre>
  
  <p>Right now I am just getting a string object. How can I get a JSON object back.</p>