Return each individual item of array

Hello, i have an array of JSON Data but i want to return each each individual item as an output so my node gets N inputs (N size of array). Is this possible? Am i being clear? Thank you

Can I get an example of the data, so that I can help you better? Is the the response of an HTTP Request?

Yes, a first i have an http response but since the array that is need is an array inside the array of responses i used a function node to return only the array of items that i need. Heres an example of the items that i need to return.

.

For example in the photo i want to return each itemData to a Cortex node, for example if my list size is of 5, 5 results to a node.

Maybe it’s a more Cortex node problem. Cortex sends all the IP’s of the array to a analyzer but only one report its returned. That’s why i thought is better to have each individual value as output so Cortex, so number adobe node is 6 (number of inputs/number of items) instead of 1 (array of items).

Hello, answering again because i need a solution if its possible. I send an array to Cortex node but only one report is being returned.

Hey @Bo_Wyatt, I haven’t used the Cortex node before but maybe something like this would be useful?

Let me know if you still run into troubles :slight_smile:

Hello, the main problem is that the input of Cortex node its indeed an array of items. I’ve used this code to create an array of the items that i need (from the HTTP Response)
vvcap 2021-03-05-13-09-14
Cortex Node receives the array returned by that node, cortex node processed all the items but it returns only one item on the response. The question is, can i iterate that array (example on the picture adobe) and return each item ? For example if the array size it’s 6 return items separately, so the green number representing the number of inputs should be 6 instead o 1.
vvcap 2021-03-05-13-11-58
Do i made myself clear? Please let me know if you don’t understand something.

Not sure if I understand but the green number is not the number of items, it is the number of runs. So it means it did run 1x and could have between 0 and an unlimited amount of items in that run.
To see the number of items you have to go into the node. It will then display it to you there.

Nodes can run multiple times if you for example have a loop or if it has multiple input connections.

Hope that makes sense.

I figured it out already, all i needed was a “for each” just like this example.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 2
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const newItems = [];\nfor (let i=0;i<10;i++) {\n  newItems.push({json: {number: i}})\n}\nreturn newItems;"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "myTest",
              "value": "=Number is: {{$node[\"SplitInBatches\"].data[\"number\"]}}"
            }
          ]
        }
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        850,
        350
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
2 Likes