Sting to object

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 [{}]?

(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.)

Hi @Shehram_Baig

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

@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!

in the http JSON body write this expression:

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

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