If condition with multiple value in an array

Hi guys!

I have a question for my workflow.

I would like to check if the array of json items have, or not, one value or more. I thought to set this node with a IF statement, where if it have more than one element it’s true, for other conditions false.

What do you think? How i do that?

This is my items array:


"contactDetails":
{
"emails":
[
"[email protected]",
"[email protected]",
"[email protected]"
],
"phonesUncertain":
[
"01932121312",
"130201"
]
}

I want to check only “emails”:

True branch: items with more than 1 email
False branch: items with 1 email or empty

Information on your n8n setup

  • **n8n version:[email protected]
  • **Database: SQLite
  • **n8n EXECUTIONS_PROCESS setting: own
  • **Running n8n via desktop app
  • **Operating system: Win

Hi @LucaDipa ,
you can use the expression {{ $json.contactDetails.emails.length }} in the if node (Number condition) and then check if the length is > 1.

See the example below:

Let me know if this solves your problem
best

2 Likes

Yes, perfect!

Thanks Giulio :slight_smile:

2 Likes

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