title: How to compare the Json responedata and sql data in java
body: <p>I written the code for Post data in webservice and it sends response data and code. Same data I am posting  in the sql using select query. My scenario is I need to check responsedata and sql data are same or not.</p>
  
  <p>Mysql.java</p>
  
  <pre><code>public ArrayList&lt;DisputeSummaryarraylistobject&gt; connectSqlconnectiondisputesummary() throws SQLException, ClassNotFoundException{
  
        ArrayList&lt;DisputeSummaryarraylistobject&gt; DisputeSummaryarraylistobjectlist = new ArrayList&lt;DisputeSummaryarraylistobject&gt;();
          String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
           "databaseName=AdventureWorks;user=UserName;password=*****";  
        try {        
           Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
           sqlConnection = DriverManager.getConnection(connectionUrl);
           String sqlStatement = "Enter the sql statement";
           stateMent = sqlConnection.createStatement();
           resultSet = stateMent.executeQuery(sqlStatement);
           DisputeSummaryarraylistobject disputeSummaryarraylistobject = new DisputeSummaryarraylistobject();
           while (resultSet.next())
           {
              disputeSummaryarraylistobject.setchargeback(resultSet.getInt("chargeback"));
              disputeSummaryarraylistobject.setactiveDisputes(resultSet.getInt("activeDisputes"));
              disputeSummaryarraylistobject.setrecentUpdates(resultSet.getInt("recentUpdates"));
              disputeSummaryarraylistobject.setrecentlyClosed(resultSet.getInt("recentlyClosed"));
              disputeSummaryarraylistobject.setresponseRequired(resultSet.getInt("responseRequired"));
              disputeSummaryarraylistobject.inProgress(resultSet.getInt("inProgress"));
              disputeSummaryarraylistobject.setclosedInFavor(resultSet.getInt("closedInFavor"));
              disputeSummaryarraylistobject.setclosedChargebacks(resultSet.getInt("closedChargebacks"));
  
              DisputeSummaryarraylistobjectlist.add(disputeSummaryarraylistobject);
           }
        }
       catch (Exception e) {
           e.printStackTrace();
        }
       return DisputeSummaryarraylistobjectlist;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Myjsonresponse.java</p>
  
  <pre><code>public void convertResponseoutputtojsonobject() throws IOException, ParseException {
  
      logger.info("convertResponseoutputtojsonobject() : BEGINs "); 
      JSONParser jsonParser = new JSONParser();
      Object object = jsonParser.parse(response.toString());
      JSONArray jsArray = (JSONArray) object;
      Iterator&lt;JSONObject&gt; iterator = jsArray.iterator();
      while (iterator.hasNext()) {
          JSONObject jsonObj = iterator.next();
          list.add(jsonObj);          
      }
      logger.info(list.toString());
      logger.info("convertResponseoutputtojsonobject() : ENDS "); 
  }
  </code></pre>
  
  <p>output : response data will be stored in the list.tostring() with formart </p>
  
  <pre><code>{
      "chargeback": 5,
      "activeDisputes": 12,
      "recentUpdates": 10,
      "recentlyClosed": 12,
      "responseRequired": 8,
      "inProgress": 4,
      "closedInFavor": 4,
      "closedChargebacks": 8
    }
  </code></pre>
  
  <p>I need compare the <code>list.tostring</code> values and sql values. Anyone can give a solution how to compare?</p>