title: JSON response and converting it to a JSON object
body: <p>I have a piece of sample code to request for data from a website and the response I get turns out to be gibberish. </p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  
  public class NetClientGet
  {
  
  public static void main(String[] args)
  {
  
      try
      {
  
          URL url = new URL("http://fids.changiairport.com/webfids/fidsp/get_flightinfo_cache.php?d=0&amp;type=pa&amp;lang=en");
  
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setRequestProperty("Accept", "application/json");
  
          if (conn.getResponseCode() != 200)
          {
              throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
          }
  
          System.out.println("the connection content type : " + conn.getContentType());
  
          // convert the input stream to JSON
          BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
  
          String output;
          System.out.println("Output from Server .... \n");
          while ((output = br.readLine()) != null)
          {
              System.out.println(output);
          }
          conn.disconnect();
      } catch (MalformedURLException e)
      {
          e.printStackTrace();
      } catch (IOException e)
      {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>How do I convert the InputStream to a readable JSON Object. Found a few questions but they already have the response and trying to parse. </p>