title: Java String to JSON conversion
body: <p>i am getting data from restful api in String variable now i want to convert to JSON object but i am having problem while conversion it throws exception .Here is my code :</p>
  
  <pre><code>URL url = new URL("SOME URL");
  
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestMethod("GET");
  conn.setRequestProperty("Accept", "application/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();
  
  
  JSONObject jObject  = new JSONObject(output);
  String projecname=(String) jObject.get("name");
  System.out.print(projecname);
  </code></pre>
  
  <p>MY string contain </p>
  
  <pre><code> {"data":{"name":"New Product","id":1,"description":"","is_active":true,"parent":{"id":0,"name":"All Projects"}}}
  </code></pre>
  
  <p>this is the string which i want in json but it shows me Exception in thread "main" </p>
  
  <pre><code>java.lang.NullPointerException
      at java.io.StringReader.&lt;init&gt;(Unknown Source)
      at org.json.JSONTokener.&lt;init&gt;(JSONTokener.java:83)
      at org.json.JSONObject.&lt;init&gt;(JSONObject.java:310)
      at Main.main(Main.java:37)
  </code></pre>