Return Object Not Array

I have some contact data that gets returned as an array, like this:

[
  {
    "contacts": [
      {
        "contactEntries": [
          {
            "entryId": "tel0",
            "label": "extension",
            "type": "tel",
            "uri": "1001"
          },
          {
            "entryId": "tel1",
            "label": "work",
            "type": "tel"
          },
          {
            "entryId": "tel2",
            "label": "cell",
            "type": "tel"
          },
          {
            "entryId": "tel3",
            "label": "home",
            "type": "tel"
          }
        ],
        "contactId": "a9a8091b-2cc7-4a4b-b31f-db9a488ad0b5",
        "displayName": "Acrobits Support",
        "fname": "Acrobits",
        "lname": "Support"
      },
      {
        "contactEntries": [
          {
            "entryId": "tel0",
            "label": "extension",
            "type": "tel",
            "uri": "115"
          },
          {
            "entryId": "tel1",
            "label": "work",
            "type": "tel"
          },
          {
            "entryId": "tel2",
            "label": "cell",
            "type": "tel"
          },
          {
            "entryId": "tel3",
            "label": "home",
            "type": "tel"
          }
        ],
        "contactId": "25353f86-64c1-4fea-9601-d369a0623319",
        "displayName": "Fancy Lawn",
        "fname": "Fancy",
        "lname": "Lawn"
      }
    ]
  }
]

The app I’m responding to is expecting just an object not an array, like this:

{
    "contacts": [
      {
        "contactEntries": [
          {
            "entryId": "tel0",
            "label": "extension",
            "type": "tel",
            "uri": "1001"
          },
          {
            "entryId": "tel1",
            "label": "work",
            "type": "tel"
          },
          {
            "entryId": "tel2",
            "label": "cell",
            "type": "tel"
          },
          {
            "entryId": "tel3",
            "label": "home",
            "type": "tel"
          }
        ],
        "contactId": "a9a8091b-2cc7-4a4b-b31f-db9a488ad0b5",
        "displayName": "Acrobits Support",
        "fname": "Acrobits",
        "lname": "Support"
      },
      {
        "contactEntries": [
          {
            "entryId": "tel0",
            "label": "extension",
            "type": "tel",
            "uri": "115"
          },
          {
            "entryId": "tel1",
            "label": "work",
            "type": "tel"
          },
          {
            "entryId": "tel2",
            "label": "cell",
            "type": "tel"
          },
          {
            "entryId": "tel3",
            "label": "home",
            "type": "tel"
          }
        ],
        "contactId": "25353f86-64c1-4fea-9601-d369a0623319",
        "displayName": "Fancy Lawn",
        "fname": "Fancy",
        "lname": "Lawn"
      }
    ]
  }

How can I accomplish this? It seems simple in my head but I can’t seem to figure it out

If there is only ever one item, this workflow should do it, the key is using the Set node with Keep Only Set and {{ $json[0]["contacts"] }}:

Note: if your data is coming from a HTTP request node you might avoid this entirely by setting the Split Into Items option to true

Okay so I tried your example (I also tweaked my webhook response to match your method) and it still shows the object in an array. Here’s a bit more of my workflow, I have an http request to get the contacts (which Split Into Items = True) then I manipulate the structure for each item in Format Portal Contact JSON to match the expected format. I then merge them back together with the function node named Merge contact items into Contacts array:

const contacts = []

let counter = 0;
do {
  try {
    const items = $items("Format Portal Contact JSON", 0, counter).map(item => item.json);
    contacts.push.apply(contacts, items);
  } catch (error) {
    return {contacts};  
  }

  counter++;
} while(true);

I tried doing this with the Item Lists node but it gives the same result

So with a little tweaking, I was able to make this work by referencing the item in the Set node. Thanks for the help!