I am attempting to get some data in the following output format, where all earnings with the same paymentID are grouped together, showing the total payment amount (sum of earnings), as well as all the earningIDs:
Currently I have an iterator, a filter, and then an aggregator set up with group by set to paymentId (this is only where the important bit starts):
This gives me a very nice grouped output:
Now I want to go to the desired format from image 1. The payment ID and total payment amount work fine. The problem I am facing is that I cannot get the earningIds array in the correct format (with the square brackets, commas, and quotation marks). I have tried to use the following:
But this gives me:
This is obviously not a valid json.
I thought this was a stupid mistake at first but then I tried putting the map(38. Array[ ];0) on its own in a variable and I got exactly what I needed (whaaat):
I then tried to just reference this variable in the next module but this also does not work.
In the end, I want to know how I can work with my data without having to worry about stringifying things and then making jsons again. It just seems that I have proper formatted data, which I then waste by turning it into text, then I have to struggle to get it back. Any help on this would be appreciated, whether its trying a completely different approach or just making this one work.
PS, I can send the outputs and flow etc if necessary but I felt like these images explain enough.