Let me say upfront that I’m new to n8n and to JavaScript. I hope the community is patient.
I have a JSON object that contains nested arrays and I’m trying to get a URL value that each item in the parent array contains.
The JSON object looks something like this:
count: 2
next: null
.
.
“results”: [
{ // results[0]
“key1”: value
.
.
“expeditions”: [
{ // expeditions[0]
“id”: Int
.
.
“url”: String
},
{ // expeditions[1]
“id”: Int
.
.
“url”: String
},
{ // expeditions[n]
}
] // end of expedition array
},
{ // results[1]
“key1”: value
.
.
“expeditions”: [
{ // expeditions[0]
“id”: Int
.
.
“url”: String
},
{ // expeditions[1]
},
{ // expeditions[n]
}
] // end of expeditions array
},
{ // results[n]
}
] // end of results array
There is results array that contains an expeditions array. What I am trying to grab is the url of the first expeditions’ item in each results item: results[n].expeditions[0].url
I’ve tried using Split Out nodes. I’ve gotten close with the Split Out nodes but can’t find a way to grab the url item from the last split. It’s also not very elegant using multiple Split Outs. I’m certain there’s a better way.
I’ve also tried Code nodes but after hours of struggling, I have to admit that I don’t know enough JavaScript to get what I want. I’ve used the n8n AI as well as Gemini and DeepSeek for assistance but the suggested code has always had some kind of error. My intuition tells me it shouldn’t be that difficult which has made the struggle pretty frustrating.
- n8n version: 1.78.1
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main): manual
- Running n8n via (Docker, npm, n8n cloud, desktop app): n8n
- Operating system: Ubuntu
I would love to learn how it can be done.
Thanks for your attention -