Forum Discussion
vgautam64 - I believe this solves your question in the simplest way I can think of. Use a Mapper snap with the following configuration:
It appears to me that you only need the field elements and values from the first group element: $group[0]
The two jsonPath statements are simply pulling all values for the Debit and Credit Amounts into an array of numbers
Finally, the Array.reduce() method is used to aggregate that list of numbers into a final total.
Hope this helps!
Can you provide some sample data on what are we trying to achieve here.
I want to compare the prev_excptn.body object to the next_excptn.body object in the following example and create the output at the bottom showing the differences in the two.
[{ "dime_id": 10202, "deleted_flag": false, "start_dt": { "_snaptype_localdatetime": "2017-05-09T19:31:33.000" }, "prev_excptn": { "body": { "id": 44, "eModel": { "id": 104, "eType": { "id": 56 }, "name": "Thing" }, "sN": "00000064", "objectA": { "eId": 32, "mK": "werfewfe", "aUserId": 36, "aDateTime": { "dateTime": "2017-05-10T13:49:22+0000", "zone": "UTC" } } }, "created": { "dateTime": "2017-05-10T13:49:21+0000", "zone": "UTC" } }, "next_excptn": { "body": { "id": 44, "eModel": { "id": 104, "eType": { "id": 9999999999 }, "name": "Thing" }, "sN": "00000064" }, "created": { "dateTime": "2017-05-10T14:03:21+0000", "zone": "UTC" } }
}]
The output would be something like this. I’m not set on this structure. I just want to only include the fields that didn’t match and their values. I used DNE on the next_excptn to show it Does Not Exist.
[{ "diff": { "body": { "eModel": { "eType": { "id": { "prev_excptn": 56, "next_excptn": 9999999999 } } }, "objectA": { "prev_excptn": { "eId": 32, "mK": "werfewfe", "aUserId": 36, "aDateTime": { "dateTime": "2017-05-10T13:49:22+0000", "zone": "UTC" } }, "next_excptn": "DNE" } } }
}]
I have spent a lot of time on this and am not yet done. It is tricky when fields don’t exist or they are many levels deep.
Related Content
- 2 years ago
- 3 years ago