Formatting Json

Hey,

I need some help figuring something out. I tried searching the forums and although I found some usefull posts it was not completely applicable to my case, which made it difficult to apply it.

From a HTTP-request I am getting a peculiar JSON result

[
  {
    "headers": [
      "header1",
      "header2",
      "header3",
      "header4",
      "header5",
      "header6",
      "header7",
      "header8",
      "header9"
    ],
    "values": [
      [
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        },
        {
          "data": "data",
          "text": "text"
        }
      ],
    ]
  }
]

As you can see there are 2 (in my opinion) strange things:

  • Headers are seperate
  • All 9 fields are in seperate objects instead of 1

My question is would it be possible to

  1. Combine/merge all objects within the brackets ([]) together?
  2. Add the headers to those objects instead of the text label?
  3. Remove the data-fields?

I have already removed/changed quiet some things, but these last 3 i cannot seem to figure out :frowning:

Information on your n8n setup

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

Hi @HamzaJ, n8n has changed a bit since version 0.193.5, so my first suggestion would be to upgrade to the current version of n8n, then adding a new HTTP Request node from scratch (not just copying the old one).

Especially when it comes to arrays in the response, this might already simplify things for you. Once done, perhaps you can provide an updated example of the data structure as well as the data structure you would like to see after your transformations?`

Purely based on your description I’ve built the below using [email protected], but I am not 100% sure that’s actually what you are trying to achieve here:

Hi @MutedJam

Thanks for your quick response. I tried your workflow and although it comes close. It isn’t what I was looking for. Ill take your advice and upgrade to the newest version, try it again and report my findings

Thanks