title: How to extract json data from the response - Java
body: <p>I am trying to extract data from Json string which is obtained by a response using only Java code.
  I am posting my Java code here.</p>
  
  <p>OUTPUT:</p>
  
  <pre><code>Entering into while loop
  [{"name":"Frank","food":"pizza","quantity":3}]
  </code></pre>
  
  <p>This is my Java code.</p>
  
  <pre><code>public void receive() 
  {    
  System.out.println("Entering into sendNote method");   
  try {
  // make json string,
  String json = "{\"name\":\"Frank\",\"food\":\"pizza\",\"quantity\":3}";
  // send as http get request
  URL url1 = new URL("http://myurl/file.php?usersJSON="+userList);
  URLConnection conn1= url1.openConnection();
  //I am receiving exactly what I have sent....
  BufferedReader rd = new BufferedReader(new InputStreamReader(conn1.getInputStream()));
  String line;
  while ((line = rd.readLine()) != null) 
  {
  System.out.println("Entering into while loop");
  System.out.println(line);// line contains the received json parameters
  //I want to enter the recieved parameters into my database
  //
  //
  //
  //I need the solution right here....
  }
  rd.close();
  } 
  catch (Exception e) 
  {
  System.out.println("Error Occured while receiving");
  e.printStackTrace();
  }
  }
  </code></pre>
  
  <p>Thank you !!!!!</p>
  
  <p>@Ankur:
  This is how I tried,</p>
  
  <p><img src="https://i.stack.imgur.com/Iwu3o.jpg" alt="This is one of your second ways... I called the function from where I wanted and passed the variable &quot;line&quot; containing the json string"></p>
  
  <p>@ Lahiru Prasanna, @ankur-singhal 
  Thanks a lot.!!</p>