Unnest an array - remove opening and closing square brackets

I have a Set Variable module after an array aggregator that returns an array in this format:

[
  {
  "hourType: [
    {
      "ID": "67c88cc4005f15d1a450b42e8932d576"
    },
    {
      "ID": "67c88cc4005f15ce84e5c76a6eb095bd"
    }
   ]
  }
]

When I try to write it to a Workfront project it fails because it’s not expecting the opening and closing square brackets. How can I eliminate thos square brackets so I end up with this format that it will accept:

{
  "hourType": [
    {
      "ID": "67c88cc4005f15d1a450b42e8932d576"
    },
    {
      "ID": "67c88cc4005f15ce84e5c76a6eb095bd"
    }
  ]
}

Thanks in advance for any advice!

Welcome to the Make community!

Instead of using the Set Variable module, you need to convert the array to JSON.

To do this, you can try using the JSON “Transform to JSON” module —

Transforms any object to JSON.

For more information, see https://www.make.com/en/integrations/json, and https://www.make.com/en/help/app/json in the help centre.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Thanks @samliew, I was able to use a Create JSON module with a new data structure that turned it into a single array housing a collection.

1 Like