Loop item inside content

Hello everyone,
My goal is to loop the items from input and use them in IF node
My input is like the screenshoot:

So i have x number of items, and I would like to check the string for every items, classic loop.

I’ve tried using an expression inside the expression, but doesn’t work, for example use {{$runIndex}} as index of the expression.

the perfect solution should be do all inside an IF node
{{ $json["body"]["content"][0]["type"] }}

I’ve also tried to use an Expression like this:

Do you have any other idea?

Hey @Gabriele_Bracciali,

I have 2 thoughts on this one… You could use an Item List node and set that to body.content then use an if node after that or in your code node you can use the $input.item.json option which I think is inserted into the node when you first open it so you would want something like…

let ris;
var length = $input.item.json.body.content.length;
for (let i = 0; i < length; i++) {
  ris = $input.item.json.body.content[i].type;
return { json: { ris } };

Some examples can be found in the workflow below.

1 Like

Great and easier than mine, I didn’t thoughts to use Item List node, actually it’s really usefull!
Thank you, really fast and clear!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.