Flatten a bundle and separate by commas

Hello everybody,

I’m trying my best to create a json type of formatting on a bundle of strings so I can send it directly into a request for another soft.

Every time a new contrat is created, business days and hours are sent as a true/false output, with hours attached. I managed to clean up the output so it looks like what my request wants. But I can’t for the life of me figure out how to flattend everything into a nice string, separating each item by a comma.

This is what I have in hand so far :

Can someone explain how I can transform this into a string like so :

[
{
“dayOfWeek”: 1,
“openingHours”: “10:49”,
“closingHours”: “16:49”
} ,

{
“dayOfWeek”: 2,
“openingHours”: “10:49”,
“closingHours”: “16:49”
} ,

[…]

]

You’ll just need a “Text Aggregator” module with the following:

Output (valid JSON):

2 Likes

Thank you for your reply, unfortunately the request I am trying to send doesn’t take empty brackets like so : {}, and sends me back an error 500.

I tried sending a request without those brackets and it seems to work. It means I need to get rid of them entirely, not just leaving the blanks.

Thank you again for taking the time to help me on this.

2 Likes

I think I found a workaround that seems to be doing the trick, as I created a module that looks like this :

This way it prevents any empty brackets from messing up my request. I did the same in case the customer was closed on Friday, tweaking syntax a little bit so there wouldn’t be any trailing commas.

3 Likes

Hi @Jessy_Buchilly

Please try to use regex with in the Text parse.
image

Please learn and try regex Link

Please try with this (?<={\n)([\s\S]*?)(?=\n})

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes