Removing wrapping Square brackets from JSON

I am joining an API JSON that has multiples items into single item following the documentation: https://docs.n8n.io/reference/javascript-code-snippets.html#_2-create-a-single-item-from-multiple-items

But I see in this case I have an issue, the API gets wrapped in Square brackets in which the system that I am importing does not accept wrapping square brackets.

Ideally should be only without wrapping “[]”

"["
{
    data_object: [
      {
        "id": 1,
        "name": "Jim"
      },
      {
        "id": 2,
        "name": "Stefan"
      },
      {
        "id": 3,
        "name": "Hans"
      }
    ]
  }
"]"

My results:
[{“records”:[{“id”:“recvwZHRICpLaVf97”,“fields”:{"…}]

What I should get:
{“records”:[{“id”:“recvwZHRICpLaVf97”,“fields”:{"…}

Is this possible? If I need to share flow, let me know how I can share privately. Thank you very much.

Are you referring to the [] in the JSON view? That represents the different items that flow through the workflow. You can ignore those.

If you really get a wrong result, a workflow is only helpful if we can execute it and get the same data you receive.

Hi @jan,
How to ignore those since they also result from the API call? If I run these results via webhook, I get the [], if I run via another API provider (as I had originally) by default it has no []. Thanks.

What I was saying is that if you use the JSON view and it looks like this:
Screenshot from 2021-04-18 00-00-56

Then the data of that one item is actually just:
Screenshot from 2021-04-18 00-01-45

Hi @jan,
I fixed it now differently, but if you mean inside the data_object correct, but when data is displayed as a single item, the [] are wrapping the single item array, I can show you two different endpoints and n8n gives different output than when I ran the other API.

n8n webhook
image

Different API builder provider
image

I am pulling this data into a website (php), I was able to fix just now by calling via “$data[0]” for n8n endpoint while originally (for the other provider) I used only $data.

I can share in private (sensitive data) the 2 different endpoints just for the curiosity of it, you will see what I mean :slight_smile: .

Thanks for the help though :slight_smile:, much appreciated.