Unsure how to extract data after using "Group By"

So I am trying to handle a JSON containing array objects in the structure like:

files: [
{ path: building.png
id: 1
bytes: 500
},
{ path: orange.png
id: 2
bytes: 55
},
{ path: work.txt
id: 3
bytes: 33
}
]

what I want to output is a new array containing the IDs of image files. So the output would need to be
[1,2]

the way I am trying to do this is firstly via an iterator, and then an array aggregator, though I am not sure if this is the way to do it

Iterate though the
“files” object

and in the aggregator on id, I am doing a “group by”: contains(path;.png)
so this should give me 2 output bundles, one is
true: [1,2]
the other is
false: [3]

if I plug the array into my next step, I see that it executes twice, one for each “sub” set (true/false)
because I cannot test this in isolation, I’m getting close to my monthly executions, and not getting close to finding out how I can extract just the one “true” version of my group by.

1 Like

Hey @palo

In “group by” field, you should use {{last(split(path;.))}}. Then you should set a filter “IMTKEY is equal to png”

Regards,
Msquare Automation - Platinum Partner of Make
@Msquare_Automation

2 Likes

thanks for that pointer,
It seems I cannot run the “last” function because its expecting “path” to be an array,

Path is just a string
files is an array of objects, so I am iterating over the “files” array.
path is a key in the object.

I believe my true/false approach was correctly separating out the file types I wanted (albeit hardcoded.

I can try to re-factor to your method, but I think my main struggle is your last sentence, "Set a filter IMTKEY is equal to png".
Is that set at the path to the next module?

UPDATE:
ahh, yes just a filter in the path works fine, I just need the text so I am aggregating from array to text filtering out by true where the file contains .png
thanks @Msquare_Automation!

1 Like

@palo I didn’t understand what you said. But glad it worked. If you found an answer as a solution. We would appreciate marking that as a solution. This will keep community healthy and organized.

Regards,
Msquare Automation - Platinum Partner of Make
@Msquare_Automation