# Create Json

**URL:** <https://community.n8n.io/t/create-json/2059>\
**Category:** Questions\
**Created:** [August 17, 2020, 1:59pm UTC](https://community.n8n.io/t/create-json/2059 "2020-08-17T13:59:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mattias\_Larsson](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mattias_larsson/32/293_2.png) [@Mattias\_Larsson](https://community.n8n.io/u/Mattias_Larsson)\
**Post date:** [August 17, 2020, 1:59pm UTC](https://community.n8n.io/t/create-json/2059/1 "2020-08-17T13:59:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [August 17, 2020, 4:59pm UTC](https://community.n8n.io/t/create-json/2059/2 "2020-08-17T16:59:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Mattias\_Larsson](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mattias_larsson/32/293_2.png) [@Mattias\_Larsson](https://community.n8n.io/u/Mattias_Larsson)\
**Post date:** [August 18, 2020, 6:46am UTC](https://community.n8n.io/t/create-json/2059/3 "2020-08-18T06:46:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ljcn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ljcn/32/2726_2.png) [@ljcn](https://community.n8n.io/u/ljcn)\
**Post date:** [February 16, 2021, 5:10pm UTC](https://community.n8n.io/t/create-json/2059/4 "2021-02-16T17:10:17Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [February 16, 2021, 5:21pm UTC](https://community.n8n.io/t/create-json/2059/5 "2021-02-16T17:21:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ljcn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ljcn/32/2726_2.png) [@ljcn](https://community.n8n.io/u/ljcn)\
**Post date:** [February 16, 2021, 5:25pm UTC](https://community.n8n.io/t/create-json/2059/6 "2021-02-16T17:25:07Z")

</div>

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

```auto
{
  "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! 🙂

---

<div class="post-metadata">

**Author:** ![ljcn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ljcn/32/2726_2.png) [@ljcn](https://community.n8n.io/u/ljcn)\
**Post date:** [February 16, 2021, 5:31pm UTC](https://community.n8n.io/t/create-json/2059/7 "2021-02-16T17:31:04Z")

</div>

I’ve used this as a function:

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

```

Which returns:

```auto
    [
      {
        "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!

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [February 16, 2021, 5:36pm UTC](https://community.n8n.io/t/create-json/2059/8 "2021-02-16T17:36:33Z")

</div>

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
          }
        ]
      ]
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![ljcn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ljcn/32/2726_2.png) [@ljcn](https://community.n8n.io/u/ljcn)\
**Post date:** [February 16, 2021, 6:17pm UTC](https://community.n8n.io/t/create-json/2059/10 "2021-02-16T18:17:05Z")

</div>

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