How do I wrap fields inside a another field

I am trying to wrap a set of existing JSON fields into another field above them all. I plan to feed a file with multiple rows into this flow, each row needs to be looped through this process (I know how to do the looping already).

Original data output looks like this:

Key-value pairs. I’m taking a CSV file and converting to a JSON like this.
image

I want it to be converted to this:

Object at root, key-value pairs within for each row
image

I have tried using Aggregate, Summarize, etc, but these all wrap the fields into a JSON array(?) which is what I cannot use.

Aggregate results like this, which my following nodes are unable to accept:
image

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Bump for visibility. I sense this is either a quick fix, or if a little complex then it probably involves a Code node. Any thoughts?

Hey @protechtedd

Would you be able to share your workflow with some pinned dummy data? That would make it easier to understand what’s going on with your data structures.

Thanks!

@protechtedd , are you trying to achieve something like this?

For that, no aggregate function is needed. Set node will do. The outcome is in the form

{
  "Layer": {
    "Column1": "a",
    "Column2": "b",
    "Column3": "c"
  }
}
2 Likes

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