Remove array inside another array

Hi there! Just curious on how can I remove an array inside an array? I am trying to make this:
image
only look like this:
image
Thanks!

because as of now it looks like this when i am trying to access the data:
image
but i want it to be like this:
image
just so i could transfer the data to mysql node easily
Thanks!

Hey @gnik31!

You can use the Function node for that. Note that the Function node returns an array. Sharing a code snippet with you that might help

var newArr = []
// code to transform/extract the data
newArr.push({json: {Key1: value1, Key2: value2}})

return newArr

Please let us know if you have any other questions. You can read more about the data structure in n8n here

Hope this helps!

1 Like

Will try this @harshil1712! Thank you so much!

1 Like

Made it! Thank you so much! @harshil1712
image

1 Like

Awesome! I am glad it is solved!

Have fun!

1 Like

Hi, sorry I’m new to n8n and TS as a language… I can not get an array of items out; similar but slightly different because I have multiple items.
e.g.

[
  [
    {
      "Key": "ec37c11e-2b67-49c6-8a58-6eccb7dd75ee",
      "Name": "Customer"
    },
    {
        "Key": "0dbdbf8a-d80c-48e6-b453-bb7862445b7c",
        "Name": "InventoryItem"
    },
    {
        "Key": "6d2dc48d-2053-4e45-8330-285ebd431242",
        "Name": "Supplier"
    },
    {
        "Key": "dcb382dc-a4e0-4354-a845-b7d647f610f7",
        "Name": "CustomField"
    }
  ]
]

I’ve been trying to go over the documentation but there are a few 404’s when important. e.g. as in " Information about how the data is structured can be found on this page about data structures."

Ok so this is what ended up working to structure it how I needed it…

const newItems = [];

var max = $node["HTTP Request"].json.length;
for (let i=0;i<max;i++) {
  newItems.push({json:{ key: $node["HTTP Request"].json[i]["Key"], Name: $node["HTTP Request"].json[i]["Name"]}});
}

return newItems;

I’m sure this could be cleaner…

We have a new node that we’re putting the finishing touches to that will do exactly this.

1 Like

Hi
what is the node name ?

The ‘split out items’ operation of the ‘item lists’ node.