0

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}]
Sucheta
  • 13
  • 4
  • 1
    Please try working this out by yourself, and add more details about what are the things that you tried. StackOverflow isn't really the platform to ask "Solve this problem for me" kind of questions. Trying to solve it by yourself would be helpful in you understanding the solution as well, and help you to be a better software developer. – Kenpachi Feb 02 '23 at 07:08
  • Library _Josson & Jossons_ has JSON datasets join and transformation operations and is capable to do you request by simple expressions. I'm the author of the library. If you want to try, I can post the solution. – Raymond Choi Feb 02 '23 at 08:57

0 Answers0