Return a field in my json input as output in a code node

I have a json input that looks something like this:

[
{
“headers”: {
//some data
},
“params”: {},
“query”: {},
“body”: {
// some data,
“employees”: [
{
“first_name”: “Osarumen”,
“last_name”: “Alohan”,
“position”: “Backend Engineer”
},
{
“first_name”: “Bill”,
“last_name”: “Gates”,
“position”: “CEO”
}
]
}
}
]

I want to output the array of ‘employees’ from the code node so I can loop over and add them to a database. I’m unable to find a solution that works from the docs and I keep getting errors. Please help

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

n8n version: 1.12.1
running n8n via: n8n cloud
operating system: windows

Hey @Osas,

Have you tried using the Split Out node on body.employees that will give you something like this.

You can find a test workflow below for this.

Thanks a lot @Jon. This helped. However I noticed that when I attempt to use input from a node not immediately preceding the split out node I get an empty output

Hey @Osas,

Yeah if you are splitting out the data we expect it to be from the node before it, If you wanted to go further back you would need to use a code node and manually write out a bit of code to get the data from the previous node and split it out into items.

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