title: Getting JSON response as part of Rest call in Java
body: <p>I am trying to make rest service call in Java. I am new to web and rest service. I have rest service which returns json as response. I have the following code but I think its incomplete because I dont know how to process output using json.</p>
  
  <pre><code>public static void main(String[] args) {
          try { 
  
              URL url = new URL("http://xyz.com:7000/test/db-api/processor"); 
              HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 
              connection.setDoOutput(true); 
              connection.setInstanceFollowRedirects(false); 
              connection.setRequestMethod("PUT"); 
              connection.setRequestProperty("Content-Type", "application/json"); 
  
              OutputStream os = connection.getOutputStream(); 
             //how do I get json object and print it as string
              os.flush(); 
  
              connection.getResponseCode(); 
              connection.disconnect(); 
          } catch(Exception e) { 
              throw new RuntimeException(e); 
          } 
  
      }
  </code></pre>
  
  <p>Please help. I am new to rest services and json. Thanks a lot in advance.</p>