I want to join two json objects on the basis of their ids.
List<JsonObject> result1 = getRecordsFromDB1();
List<JsonObject> result2 = getRecordsFromDB2();
result1 = [{"ID_COL":"Table1","DB1_TABLE_NAME":"Table1","DB1_COUNT":"10"}, {"ID_COL":"Table2","DB1_TABLE_NAME":"Table2","DB1_COUNT":"20"}}];
result2 = [{"ID_COL":"Table1","DB2_TABLE_NAME":"Table1","DB2_COUNT":"10"}, {"ID_COL":"Table2","DB2_TABLE_NAME":"Table2","DB2_COUNT":"40"}}];
I want to calculate the difference between the count for each table in both the databases.
I want two lists success and reject in the following format where I can have the table name from both the database alsong with a property DIFF_COUNT which is the difference between DB2_COUNT-DB1_COUNT. If difference in count is 0 than success else reject.
List<JsonObject> success = [{"ID_COL":"Table1","DB1_TABLE_NAME":"Table1",DB2_TABLE_NAME:"Table1","DIFF_COUNT":0}]
List<JsonObject> reject = [{"ID_COL":"Table2","DB1_TABLE_NAME":"Table2",DB2_TABLE_NAME:"Table2","DIFF_COUNT":20}]