# Formatting Array Items

**URL:** https://community.make.com/t/formatting-array-items/45560
**Category:** Questions
**Tags:** arrays, mapping
**Created:** [July 11, 2024, 8:40am UTC](https://community.make.com/t/formatting-array-items/45560 "2024-07-11T08:40:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![alexs](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alexs/32/23635_2.png) [@alexs](https://community.make.com/u/alexs)
#### Post date: [July 11, 2024, 8:40am UTC](https://community.make.com/t/formatting-array-items/45560/1 "2024-07-11T08:40:04Z")

</div>

If I have an arrays of items like:

```auto
{
    "Away": [
        32b5edf9-b8a6-426e-b860-7e7116dd2b10,
        c41f69ae-e542-4095-934d-04511699aaad
    ],
    "Preference": [
        14ee157f-98bf-4f70-b092-eea9eaa759e1
    ]
}

```

How can wrap the items in each array in speechmarks, without iterating through each separate array and using a text aggregator to do that? There must be a simple way to apply some formatting to the items in each array?

The output should be:

```auto
{
    "Away": [
        "32b5edf9-b8a6-426e-b860-7e7116dd2b10",
        "c41f69ae-e542-4095-934d-04511699aaad"
    ],
    "Preference": [
        "14ee157f-98bf-4f70-b092-eea9eaa759e1"
    ]
}

```

I’m extracting the list of IDs that populate each array in a map() function so if I can add the speechmarks while extracting the IDs, that’d also solve my problem.

Ultimately, I need to send the arrays as valid JSON in a webhook response.

---

<div class="post-metadata">

### Author: ![Benjamin\_from\_Make](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/benjamin_from_make/32/37894_2.png) [@Benjamin\_from\_Make](https://community.make.com/u/Benjamin_from_Make)
#### Post date: [July 11, 2024, 9:28am UTC](https://community.make.com/t/formatting-array-items/45560/2 "2024-07-11T09:28:29Z")

</div>

Hi!

If I understand it well, you are getting this JSON file (with an incorrect format) as a String and you want to add the speechmarks before you can return it in the payload of your webhook response?

How did you get this json? Maybe there is something we can do before to avoid this format?  
If ever it’s not possible to correct this initial data, we could still use regular expressions to correct it.

I can try and help you with it

Benjamin

---

<div class="post-metadata">

### Author: ![alexs](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alexs/32/23635_2.png) [@alexs](https://community.make.com/u/alexs)
#### Post date: [July 11, 2024, 12:29pm UTC](https://community.make.com/t/formatting-array-items/45560/3 "2024-07-11T12:29:47Z")

</div>

Thanks for the quick reply!

The json is coming from a list of Notion page IDs that I’ve fetched in a previous step, which I then aggregate into groups of arrays in an array aggregator step.

 ![CleanShot 2024-07-11 at 13.29.29@2x](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/d/e/de47b47c770bafd3473101f1a373babd1c4a5866.jpeg)

---

<div class="post-metadata">

### Author: ![Benjamin\_from\_Make](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/benjamin_from_make/32/37894_2.png) [@Benjamin\_from\_Make](https://community.make.com/u/Benjamin_from_Make)
#### Post date: [July 11, 2024, 12:55pm UTC](https://community.make.com/t/formatting-array-items/45560/4 "2024-07-11T12:55:15Z")

</div>

Maybe you could use a Text Aggregator instead of the Array aggregator so that you have more control over the Json doc you want to build. I’m just wondering, you have 2 arrays in your document; does it mean you have to generate the 2?

And if ever there is no simple way to do it; I have an ugly solution with replace functions and regex. I started to test, it’s possible we can do it combining 3 replace functions, but I need to see the raw JSON that you get. The one you give here seems to have extra carriage returns.

So, eventually, can you show me more how you have generated the first JSON (I mean before the set Variable), and/or can you send a raw version of the JSON you are trying to correct, so that I can try with regex?

Benjamin

---

<div class="post-metadata">

### Author: ![alexs](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alexs/32/23635_2.png) [@alexs](https://community.make.com/u/alexs)
#### Post date: [July 11, 2024, 2:40pm UTC](https://community.make.com/t/formatting-array-items/45560/5 "2024-07-11T14:40:38Z")

</div>

> [@Benjamin\_from\_Make](#):
>
> Maybe you could use a Text Aggregator instead of the Array aggregator so that you have more control over the Json doc you want to build.

Thanks for the suggestion, that worked!

---

<div class="post-metadata">

### Author: ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)
#### Post date: [July 26, 2024, 8:19am UTC](https://community.make.com/t/formatting-array-items/45560/6 "2024-07-26T08:19:03Z")

</div>


