How to aggregate array into JSON?

Hello,

I am struggling with bundles and arrays.

In my scenario, I get data about an item (Booking) via an API request , then I iterate through sub item (fees) that I got as an output. I then aggregate the output of each of this sub item.

What I want is get a single output with all the object into a json object that I can add to my DB in the next steps.

Here is my iterator :

The aggregator :

At first I used the array data from the aggregator (in the module to add data to my DB), got this error :


When using the Array (not the array data) I don’t have mistakes but I end up with this value in my DB [Collection].

Ideally I would want a json object as an array :

[
  {
    "booking_fees": {
      "name": {
        "en": "$value"
      },
      "price": "$value"
    }
  },
  {
    "booking_fees": {
      "name": {
        "en": "$value"
      },
      "price": "$value"
    }
  },
  {
    "booking_fees": {
      "name": {
        "en": "$value"
      },
      "price": "$value"
    }
  }
]

Thanks in advance for the help ! 

You can either use the JSON “Aggregate to JSON” module, or a text aggregator.

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

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

Thanks @samliew

I tried the text aggregator, I don’t have the error anymore, but the output I have from the text aggregator here this :

[Collection], [Collection], [Collection], [Collection], [Collection]

Here is how I set up the array aggregator and text aggregator :slight_smile:

You actually have to type out each “object” in the Text Aggregator.

{
    "booking_fees": {
      "name": {
        "en": "$value"
      },
      "price": "$value"
    }
  }

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.

@samliew I tried hat you suggested and it’s in progress !

But in my text aggregator output I only have one object, the first one, whereas I had 2 bundle out of the aggregator.

Here is what I did :


whereas I have as we can see 2 bundles :