Search code examples
javascriptjsonn8n

N8N: Remove JSON Key in output


I am trying to remove the json key in my output file. What is the best approach to do this? not sure how to achieve this. I want to return the array of data with all values. Not necessarily 1 value.

This is a link to my N8N post: Manipulate JSON File Structure to endpoint

below is my structure

current output:

{
  "data": [
    {
      "id": 21428
    }
  ]
}

and i want to remove {"data": to get this outcome.

[
   {
     "id": 21428
   }
]

enter image description here

enter image description here

i have tried changing my item list to split output but no success.


Solution

  • You can simply reassign the output with the value of data object:

    output = output.data;
    

    let output = {
      "data": [
        {
          "id": 21428
        }
      ]
    };
    output= output.data;
    console.log(output);