Create Json

Is there any node except function nodes that can be used to create a JSON something similar to SET node. The problem with the function node is that there is no way to map items and it takes to long to copy every path? I want it to be independent of the HTTP node as well.

Not sure if I understand what you want the node to do exactly. Can you please give an example.
Do you mean literally a JSON-string or really a JavaScript-Object?

I would like a node similar to SET or the HTTP but where you could build a custom JSON and where the function is there to map against earlier nodes.

So lets say just like the HTTP requests are working with rawbody but where the node only should create a JSON and not make HTTP request.

I hope you understand the explanation

@Mattias_Larsson Did you manage to do this?
I’m using a webhook node that replies with the last executed node and would like to serve a custom JSON using expressions to get values from other nodes

If it’s a simple object with key value pairs I guess you can use a set node and reference the data with expressions. If you want to do something more complex, you can use a function node to return the data in any shape.

Thank you, hubspot expects the returned json to look like this:

{
  "results": [
    {
      "properties": [
        {
          "label": "Example custom currency property",
          "dataType": "CURRENCY",
          "value": 99.56,
          "currencyCode": "USD"
        }
      ]
      //...
    }
    //...
  ]
  //...
}

The set node formats as a string and so presumably those quote marks affect it. I’ve done it as a function (I think) - the power of N8N is awesome, and as always the community here rocks! :slight_smile:

I’ve used this as a function:

    items[0].json = {
      results: [{"test_param": "testy"}]
    };
    return items;

Which returns:

    [
      {
        "results": [
          {
            "test_param": "testy"
          }
        ]
      }
    ]

This doesn’t seem to be working. Could this be because it sends the reply back to the webhook as an array? Sorry if I’m being dumb!

That should not be an issue as long as you set the parameter Response Data to First Entry JSON. Check the example below.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "path": "d283b542-ec4d-4a88-b204-98f784fd7656",
        "responseMode": "lastNode",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        540,
        300
      ],
      "webhookId": "d283b542-ec4d-4a88-b204-98f784fd7656"
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      results: [\n        {\n          key: 'value'\n        }\n      ]\n    }\n  }\n]\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        810,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thank you @RicardoE105 !
It turns out hubspot wouldn’t act on it because I’d not passed a mandatory parameter, oops!