Delete last character of string

Hello makers, I’m building list of items to JSON. Everything was working fine until this little comma… :
Screenshot 2024-12-05 à 17.25.50

What I’m doing is quite classic, I’m converting input array to a list of JSON pattern items by using variables from the array into :

The problem : Because of join() function, the last comma of the last item in the list make DataError in the JSON module

Do you have any solution? Is it possible to delete last character of string?

Hi,

I probably did not fully understand your issue but would this solution somehow help?

@Timbleking Thank you. Not exactly. Actually, it’s very simple, I’m creating the following JSON pattern list with the functon join() :

{
*Data here*
},

{
*Data here*
},

etc.

I would like to not generate the last comma of the last item, OR to remove it at the end because my JSON syntax is not valid just because of that :unamused:

Hello @Garry_V,
Use the replace() with regular expressions.

{{replace("{*Data here*},{*Data here*},"; "/\,(?!\s*?[\{\[\""\'\w])/"; emptystring)}}

Try this if it works?
:+1:

2 Likes

Hello @Garry_V,

Not familiar with your entire scenario, but have you considered using a JSON aggregator instead of an Array Aggregator?

2 Likes

Yes, As @Donald_Mitchell suggested try JSON Aggregator also if the current setup is not working.
If you use JSON Aggregator You also need to know about how to use Data structures: https://www.make.com/en/help/tools/data-structures#data-structures

:+1:

Thank you guys, thank you @dilipborad

I didn’t try JSON Aggregator because that works perfectly :
{{replace("{*Data here*},{*Data here*},"; "/\,(?!\s*?[\{\[\""\'\w])/"; emptystring)}}

I don’t understand how it works but it works, so I’m happy :slight_smile:

1 Like