If statement if text aggregator is in last iteration

Hello,

I am trying to create a JSON from a MySQL select call to use in an API call to HubSpot to update contacts in a batch.

I can´t figure out to create the required JSON for this.

At first I tried to use the Text Aggregator which would work fine, but I don´t know how to define that the last collection should not have a comma at the end.
If someone can give me a hint, the issue would be solved.

I tried the JSON aggregator but the format never ends up like it is needed.

So here is what I need:

{
  "inputs": [
    {
      "id": "1",
      "properties": {
        "company": "Biglytics",
        "email": "bcooper@biglytics.net",
        "firstname": "Bryan",
        "lastname": "Cooper",
        "phone": "(877) 929-0687",
        "website": "biglytics.net"
      },
    {
      "id": "2",
      "properties": {
        "company": "Biglytics",
        "email": "bcooper@biglytics.net",
        "firstname": "Bryan",
        "lastname": "Cooper",
        "phone": "(877) 929-0687",
        "website": "biglytics.net"
      },
    }
  ]
}

With the JSON aggregator I only managed to get the following formats

[
   {
      "inputs":[
         "1"
      ],
      "properties":{
        "company": "Biglytics",
        "email": "bcooper@biglytics.net"
      }
   },
   {
      "inputs":[
         "2"
      ],
      "properties":{
        "company": "Biglytics",
        "email": "bcooper@biglytics.net"
      }
   }
]
[
   {
      "inputs":[
         {
            "id":"20095051",
            "properties":{
               "company": "Biglytics",
               "email": "bcooper@biglytics.net"
            }
         }
      ]
   },
   {
      "inputs":[
         {
            "id":"7833352",
            "properties":{
               "company": "Biglytics",
               "email": "bcooper@biglytics.net"
            }
         }
      ]
   }
]

I could get rid of the brackets like described here, but the general structure doesn´t match.

Thank you so much for you help,
Ingo

Hey @Ingo ,

So for the text aggregator you can take a look at this post I created:

If you like to use the JSON module, there is a “generator” you can use for your structure. This generator allows you to easily get the structure you want. In this case you would have to use something like this:

{
	"inputs": [{
			"id": "1",
			"properties": {
				"company": "Biglytics",
				"email": "bcooper@biglytics.net",
				"firstname": "Bryan",
				"lastname": "Cooper",
				"phone": "(877) 929-0687",
				"website": "biglytics.net"
			}
		},
		{
			"id": "2",
			"properties": {
				"company": "Biglytics",
				"email": "bcooper@biglytics.net",
				"firstname": "Bryan",
				"lastname": "Cooper",
				"phone": "(877) 929-0687",
				"website": "biglytics.net"
			}
		}
	]
}

Instead of the structure you provided above (a few small fixes).

1 Like

Hi @Bjorn.drivn,

awesome. I actually found the post you linked and tried it.
Instead of adding the comma myself I let make.com do it and it works like a charm.

I will also look into the solution with the JSON aggregator.

Thank you very much!
Ingo

1 Like