title: How to convert a String to a JsonObject
body: <p>I am using a <code>HttpURLConnection</code> to get <code>Json</code> from a web into a string.</p>
  
  <p>And i'm storing web string into <code>BufferedReader</code> and after that storing it in a new <code>String</code>. </p>
  
  <p>And string is here:-</p>
  
  <pre><code>{"coord":{"lon":72.85,"lat":19.01},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":{"temp":302.131,"pressure":1024.24,"humidity":84,"temp_min":302.131,"temp_max":302.131,"sea_level":1024.75,"grnd_level":1024.24},"wind":{"speed":4.77,"deg":302.001},"clouds":{"all":12},"dt":1459677392,"sys":{"message":0.0102,"country":"IN","sunrise":1459645229,"sunset":1459689786},"id":1275339,"name":"Mumbai","cod":200}
  </code></pre>
  
  <p>How can i convert it into JsonObject.</p>
  
  <p>I've also seen this answer (<a href="https://stackoverflow.com/questions/25948000/how-to-convert-string-to-jsonobject">How to convert String to JsonObject</a>) but it's not working.</p>
  
  <p>Here is code:-</p>
  
  <pre><code>    BufferedReader br= new BufferedReader(new InputStreamReader(conn.getInputStream()));
  
      String localoutput;
      while ((localoutput = br.readLine()) != null) 
      {
              output=localoutput+output;
      }
      conn.disconnect();
      }
      catch(Exception e)
      {
          System.out.println(e);  
      }
  
  JsonReader jsonReader = Json.createReader(new StringReader(output));
  JsonObject object = jsonReader.readObject();
  jsonReader.close();
  
  try {
      String cityname = object.getString("name");
      System.out.println(cityname);
  } 
  catch (Exception e)
  {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Here output is the String which I've mentioned it earlier.
  I'm not getting the Output Cityname in my console. </p>