Mapping Array to Array of Collection

Welcome to the Make community!

Here’s how to do it in a single module (and one operation), and no Data Structures.

You can also use this method with a Parse JSON module if you want it to be returned as an array variable.

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":1,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"{\n  \"message\": \"This is a random message\",\n  \"country\": \"RW\",\n  \"recipients\": [\n    \"+250780123456\",\n    \"+250720654321\"\n  ]\n}"},"metadata":{"designer":{"x":0,"y":150},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}},{"id":2,"module":"builtin:BasicRouter","version":1,"mapper":null,"metadata":{"designer":{"x":300,"y":150,"name":"Run Examples"}},"routes":[{"flow":[{"id":3,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"{\"recipients\":[\n  {\"number\":\"{{join(1.recipients; \"\"\"},{\"\"number\"\":\"\"\")}}\"}\n]}"},"metadata":{"designer":{"x":600,"y":0,"name":"Output as array variable"},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}}]},{"flow":[{"id":4,"module":"util:ComposeTransformer","version":1,"parameters":{},"mapper":{"value":"{\"recipients\":[\n  {\"number\":\"{{join(1.recipients; \"\"\"},{\"\"number\"\":\"\"\")}}\"}\n]}"},"metadata":{"designer":{"x":600,"y":300,"name":"Output as JSON string"}}}]}]}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

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.

1 Like