Help with Jsonata grouping please

grouping.json (97.7 KB) shows two Change Nodes using Jsonata being used to de-duplicate log entries.

The first node groups & amends objects from a log by (day) date, the second strips off the date key produced by that grouping such that a simple array of objects is produced; exactly like the input.

It works fine. (There a 8 or 9 fewer elements in the clean output array than the input.)

However, I feel it's a bit feeble having to use two nodes but I couldn't find a syntax / method of grouping without having to use that grouping (day/date in this case) as an output key somewhere.

I'd be very grateful for any thoughts.

I am not 100 % sure that I understand your question, but to me it seems the easiest way would be to hande the data sequence as a stream and take a more functional approach. Take a look at Lodash's chain command. It will provide a very clean way to solve your problem.

1 Like

Many, many thanks for your reply @realjax, my apologies if I was not clear but you understood well and chaining was indeed the answer, in fact ~> function($i){$i.*} was all that was required.

I'm really chuffed at finding an answer but also depressed at how many times I've read the documentation without fully realising the implications!

1 Like