Jscript to clean json

Describe the issue/error/question

Hi! i’m trying to clean a json . The complexity is that the values are arrays of variable length. So i cannot predict how many src of images we will get (see example below) , for example i’d like to turn this json:


[
{
"categories":
[
{
"id":
1476,
"name":
"Flats",
"slug":
"flats"
},
{
"id":
1050,
"name":
"Women",
"slug":
"women"
},
{
"id":
1054,
"name":
"Women Shoes",
"slug":
"women-shoes"
}
],
"tags":
[
{
"id":
1090,
"name":
"comfortable",
"slug":
"comfortable"
},
{
"id":
1971,
"name":
"daily flat",
"slug":
"daily-flat"
},
{
"id":
1401,
"name":
"flat",
"slug":
"flat"
},
{
"id":
49,
"name":
"Footwear",
"slug":
"footwear"
},
{
"id":
1112,
"name":
"high end clothing",
"slug":
"high-end-clothing"
},
{
"id":
1085,
"name":
"High end items",
"slug":
"high-end-items"
},
{
"id":
1086,
"name":
"Items to sell",
"slug":
"items-to-sell"
},
{
"id":
1080,
"name":
"Items we love",
"slug":
"items-we-love"
},
{
"id":
1045,
"name":
"luxury",
"slug":
"luxury"
},
{
"id":
1500,
"name":
"luxury flat",
"slug":
"luxury-flat"
},
{
"id":
1972,
"name":
"summer flat",
"slug":
"summer-flat"
},
{
"id":
1462,
"name":
"women flat",
"slug":
"women-flat"
}
],
"images":
[
{
"id":
7504,
"date_created":
"2023-03-27T10:56:56",
"date_created_gmt":
"2023-03-27T10:56:56",
"date_modified":
"2023-03-27T10:56:56",
"date_modified_gmt":
"2023-03-27T10:56:56",
"src":
"https://www.primeluxuryoutfit.com/wp-content/uploads/2023/03/DSCF7090-scaled.jpg",
"name":
"DSCF7090",
"alt":
""
},
{
"id":
7505,
"date_created":
"2023-03-27T10:58:50",
"date_created_gmt":
"2023-03-27T10:58:50",
"date_modified":
"2023-03-27T10:58:50",
"date_modified_gmt":
"2023-03-27T10:58:50",
"src":
"https://www.primeluxuryoutfit.com/wp-content/uploads/2023/03/DSCF7091-scaled.jpg",
"name":
"DSCF7091",
"alt":
""
},
{
"id":
7506,
"date_created":
"2023-03-27T11:00:56",
"date_created_gmt":
"2023-03-27T11:00:56",
"date_modified":
"2023-03-27T11:00:56",
"date_modified_gmt":
"2023-03-27T11:00:56",
"src":
"https://www.primeluxuryoutfit.com/wp-content/uploads/2023/03/DSCF7093-scaled.jpg",
"name":
"DSCF7093",
"alt":
""
}
],
"id":
7497,
"dimensions":
{
"length":
"",
"width":
"",
"height":
""
},
"attributes":
[
{
"id":
1,
"name":
"Color",
"position":
0,
"visible":
true,
"variation":
false,
"options":
[
"Green"
]
}
]
}
]

into this:


[
{
"name":
[
"Flats",
"Women",
"Women Shoes"
],
"tags":
[
"comfortable",
"daily flat",
"flat",
"Footwear",
"high end clothing",
"High end items",
"Items to sell",
"Items we love",
"luxury",
"luxury flat",
"summer flat",
"women flat"
],
"src":
[
"https://www.primeluxuryoutfit.com/wp-content/uploads/2023/03/DSCF7090-scaled.jpg",
"https://www.primeluxuryoutfit.com/wp-content/uploads/2023/03/DSCF7091-scaled.jpg",
"https://www.primeluxuryoutfit.com/wp-content/uploads/2023/03/DSCF7093-scaled.jpg"
]
}
]

What is the error message (if any)?

Please share the workflow

(Select the nodes and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow respectively)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: [email protected]
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: N8N cloud

Hi @oly-dev, it seems you have already reached out our support via email as well, so I’ll go ahead and close this duplicate.