I am struggling for weeks, going through the forum to try find similar answer that can help me solve this issue.
At the last step in this workflow I am left with the output which I would like to be able to do a few things.
To start with to be able to split the three “teams” into seperate Items so that i can inser each item into a new node placeholder.
To be able to read as many lines and split those lines into seperate items. The reason for this is sometimes I might receive 3 teams as in the example, however other times maybe 13.
Thanks in advance for the help!
Please share the workflow
Share the output returned by the last node
`
[
{
“0”:“Denver Broncos”,
“1”:“Los Angeles Chargers”,
“2”:“Kansas City Chiefs”
}
]`
Information on your n8n setup
n8n version: 0.207.0
Database you’re using (default: SQLite): SQLite
Running n8n with the execution process [own(default), main]: own
Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker
to be honest I’m not 100% sure what you’re trying to achieve. Maybe you can help me to describe a little more what you’re trying to do?
But before we start, I see that you’re mocking your data in the first function node. It seems to have a very weird data structure though. Your teams inside the leagues for example are currently not using an array format
//this is your format right now:
"nfl": {0:"Denver Broncos", 1: "Los Angeles Chargers"}
// this is a format I would expect
"nfl": ["Denver Broncos", "Los Angeles Chargers"]
but some other weird format that looks like an array. Are you sure that this is the correct data format you would expect when receiving the real data?
Hi @Niklas_Hatje thanks for the pointer, this is the structure I am getting from the provider, however I will ask them to restructure it.
Basically what I am trying to do is (taking into account we get the data in the format you suggested), then be able to take the teams for NFL and insert them into a users contact card inside Mautic (basically can think of it as taking the three teams and putting them into a single cell in a google sheet).
I finally got this solved with the assistance of someone else, here is the solution that worked for me
let teams_list = ""
for (let i of item.json.body[4].nfl){
teams_list = teams_list + i + ", "
}
return {json:{'teams':teams_list.slice(0, -2)}}
// return {'ouput':Object.values(item.json.body[4])}