Creating an array with individual numbers from a string

I am trying to convert a string “35,34,33” into an array of numbers to add a contact to certain lists in my email-marketing-service.

I’m using the split-function to split the string into an array (works perfectly fine) but it seems like the separate items are then strings and not numbers.

At least I get the error: listIds/0 should be type number (invalid_parameter).

Every combination of split, parseNumber, map, etc. I’ve tried so far doesn’t work.

Is there a way to convert a string like “35,34,33” into an array of individual numbers?

Thanks a lot in advance and all the best,
Yannic

Welcome to the Make community!

You can try to accomplish this with the Parse JSON module trick:

e.g.:

{"number_array":[
  {{ join(split("35,34,33"; ","); ",") }}
]}

Paste this into a Parse JSON module.

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

You can also join us in the Make Fans Discord server to chat with other makers. Due to the evolving needs of this community, the Discord invite link can be found elsewhere on this forum. You can either search for it or request an invite.

4 Likes

wow, thank you so much for your quick reply and the great tip. Works great! :slight_smile:

1 Like