# Sting to object

**URL:** <https://community.n8n.io/t/sting-to-object/201769>\
**Category:** Questions\
**Tags:** data-structure\
**Created:** [October 8, 2025, 10:15am UTC](https://community.n8n.io/t/sting-to-object/201769 "2025-10-08T10:15:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shehram\_Baig](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shehram_baig/32/60148_2.png) [@Shehram\_Baig](https://community.n8n.io/u/Shehram_Baig)\
**Post date:** [October 8, 2025, 10:15am UTC](https://community.n8n.io/t/sting-to-object/201769/1 "2025-10-08T10:15:46Z")

</div>

I have to send data to an api, which excepts a single object but n8n always outputs a array what to do here? how can I have output just in {} and not in [{}]?

```auto
(Select the nodes {
  "nodes": [
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// In \"Run Once for Each Item\" mode, use $input.item.json\nconst data = $input.item.json;\n\nreturn {\n sourceTypeId: Number(data.sourceTypeId),\n filingUrl: data.filingUrl,\n documentType: data.documentType,\n originalID: data.originalID,\n commentOriginal: data.commentOriginal,\n tbcStyle: data.tbcStyle,\n tbcMessage: data.tbcMessage,\n botgate_s3Uri: data.botgate_s3Uri,\n n8n_workflowId: data.n8n_workflowId,\n n8n_executionId: data.n8n_executionId,\n n8n_executionStep: Number(data.n8n_executionStep),\n transmissionType: data.transmissionType,\n filingMapped: data.filingMapped || null,\n rawData: {\n filingProperties: {\n issuerName: data.rawData?.issuerName || null,\n publishingDateOriginal: data.rawData?.publishingDateOriginal || null,\n sourceNote: data.rawData?.sourceNote || null\n },\n transactionProperties: data.transactionProperties || []\n }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -460,
        -20
      ],
      "id": "1dd1f07e-f583-45fe-9a5f-40d285d92dfc",
      "name": "canonical conversions"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -720,
        -20
      ],
      "id": "760c9d4d-a9ad-4593-a8c7-20b27e03af81",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "jsCode": "const data = $input.all()[0].json;\nreturn [{ json: data }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -220,
        -20
      ],
      "id": "ba4e40ae-532f-4aa5-bac7-4627b6af8947",
      "name": "output should be an object not an array"
    }
  ],
  "connections": {
    "canonical conversions": {
      "main": [
        [
          {
            "node": "output should be an object not an array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "canonical conversions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {
    "canonical conversions": [
      {
        "sourceTypeId": 7,
        "filingUrl": null,
        "documentType": "html",
        "orilID": null,
        "comginal": "Parsed from table; decimals use comma.",
        "tbcStyle": "BLUP",
        "tbcMessage": "Currency inferred from page footer",
        "bori": "s3://bo0/8-350/34029",
        "n8n_workflowId": "wf_gb_ingest_v1",
        "n8n_executionId": "29",
        "n8n_executionStep": 1,
        "transmissionType": "LGM",
        "filingMapped": null,
        "rawData": {
          "filingProperties": {
            "issuerName": null,
            "publishingDateOriginal": null,
            "sourceNote": "HTml"
          },
          "transactionProperties": [
            {
              "Name": "Jonathan Sorrell",
              "role": "Officer",
              "type": "",
              "qty": "",
              "price": "18.38",
              "currency": "",
              "mic": "Outside a trading venue",
              "Date": "2025-10-06"
            },
            {
              "Name": "Jonathan Sorrell",
              "role": "Officer",
              "type": "Matching Award",
              "qty": "8",
              "price": "0",
              "currency": "",
              "mic": "off exchange",
              "Date": "2025-10-06"
            }
          ]
        }
      }
    ],
    "output should be an object not an array": [
      {
        "sourceTypeId": 7,
        "filingUrl": null,
        "documentType": "html",
        "originalID": null,
        "commentOriginal": "Parsed from table; decimals use comma.",
        "tbcStyle": "BLUP",
        "tbcMessage": "Currency inferred from page footer",
        "botgate_s3Uri": "s3://botgate/ingest/gb/2025/10/8-350/34029",
        "n8n_workflowId": "wf_gb_ingest_v1",
        "n8n_executionId": "34029",
        "n8n_executionStep": 1,
        "transmissionType": "LEGM",
        "filingMapped": null,
        "rawData": {
          "filingProperties": {
            "issuerName": null,
            "publishingDateOriginal": null,
            "sourceNote": "HTML table with 11 trades of 4 insiders"
          },
          "transactionProperties": [
            {
              "insiderName": "Jonathan Sorrell",
              "role": "Group Chief Executive Officer",
              "type": "Buy",
              "qty": "8",
              "price": "18.38",
              "currency": "GBP",
              "mic": "Outside a trading venue",
              "tradeDate": "2025-10-06"
            },
            {
              "insiderName": "Jonathan Sorrell",
              "role": "Group Chief Executive Officer",
              "type": "Matching Award",
              "qty": "8",
              "price": "0",
              "currency": "GBP",
              "mic": "off exchange",
              "tradeDate": "2025-10-06"
            }
          ]
        }
      }
    ]
  },
  "meta": {
    "instanceId": "a9a29e3bf27388218b7643b5702f17f6024e0c9bd6ba454fc3517b64ae4bd4b3"
  }
}on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

```

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [October 8, 2025, 11:19am UTC](https://community.n8n.io/t/sting-to-object/201769/2 "2025-10-08T11:19:52Z")

</div>

Hi @Shehram_Baig

You can use the set node with a field type object:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/f/f/ff013e16a8d3665e37453569d906913ba338400e.png)

---

<div class="post-metadata">

**Author:** ![Shehram\_Baig](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shehram_baig/32/60148_2.png) [@Shehram\_Baig](https://community.n8n.io/u/Shehram_Baig)\
**Post date:** [October 8, 2025, 1:06pm UTC](https://community.n8n.io/t/sting-to-object/201769/3 "2025-10-08T13:06:46Z")

</div>

@mohamed3nan Hi mohamed, thanks for reply thing is I cant seem to get rid off this [] wrapper making it an arrary, can you please take a look the output should be just a single object { } that I can call in http request node’s json body. thanks!

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/d/c/dcfdfe50c3f65f073f6bc0c7472c84381a504fa2.png)

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/1/5/1508186ea9d07a19beaa30bdc7014199f74cf0a7.png)

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [October 8, 2025, 1:23pm UTC](https://community.n8n.io/t/sting-to-object/201769/4 "2025-10-08T13:23:28Z")

</div>

> [@Shehram\_Baig](#):
>
> that I can call in http request node’s json body

in the http JSON body write this expression:

```auto
{{ $json.object_name.toJsonString() }}

```

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/a/4/a4344d149bbb5c928d3c6cd29bba972bfb418ac9.png)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [January 6, 2026, 1:23pm UTC](https://community.n8n.io/t/sting-to-object/201769/5 "2026-01-06T13:23:42Z")

</div>

Closed on January 6, 2026, 1:23pm UTC

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