Convert json array values into complete key-value pairs

Hi all, I’m a newbie here.
I’m working with a HTTP request node that produces results in a format that I believe is not optimal for ChatGPT to recognize or work-with.

For example, the data comes out as follows:
[
{
“columnDefinitions”: [
{
“name”: “ID”,
“type”: “String”,
“isKey”: false,
“nullable”: false
},
{
“name”: “Months”,
“type”: “String”,
“isKey”: false,
“nullable”: false
},
{
“name”: “Name”,
“type”: “String”,
“isKey”: false,
“nullable”: false
},
{
“name”: “Version”,
“type”: “String”,
“isKey”: false,
“nullable”: false
}
],
“data”: [
[
“ES1001”,
“2022 JAN”,
“Juan Pedrero”,
“2.1”
],
[
“ES1001”,
“2022 FEB”,
“Juan Pedrero”,
“2.1”
],
[
“ES1001”,
“2022 MAR”,
“Juan Pedrero”,
“2.2”
]
]
}
]

I’m looking to convert this data-set to the following format.
[
{
“ID”: “ES1001”,
“Months”: “2022 JAN”,
“Name”: “Juan Pedrero”,
“Version”: “2.1”
},
{
“ID”: “ES1001”,
“Months”: “2022 FEB”,
“Name”: “Juan Pedrero”,
“Version”: “2.1”
},
{
“ID”: “ES1001”,
“Months”: “2022 MAR”,
“Name”: “Juan Pedrero”,
“Version”: “2.2”
}

]

I’ve tried separating the list items and merging them, but it’s not been easy. Additionally, the API calls can produce various data-sets each with different fields/indexes.
Can this be programatically be achieved with a function or core n8n nodes?

You can simply use a Set node and map your data with simple javascript.

2 Likes

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