Set Key For Items From Array When Parsing JSON

I have a simple JSON stringified array like ["https:\/\/url1.com", "https:\/\/url2.com", "https:\/\/url3.com"]. I’m parsing the array to JSON which gives me a set of bundles as the output.

Now I need to aggregate the bundles to JSON but I can’t reference the urls from my bundles in the Aggregate To JSON step, presumably because the items in my bundles don’t have keys.

So how can I assign a key to each bundle to create bundles like url: url1, url: url2, url: url3? I’d like to avoid iterating over the bundles just to assign keys to them, to avoid wasting operations.

These are the bundles that I’m working with -

Defining the data structure like this doesn’t have any effect, I still just get a set of bundles containing the urls no keys as the output of the parse JSON step -

Turns out setting the data structure like that does work, its just that the keys aren’t displayed in the module’s output, fun times.

1 Like

Iterating doesn’t waste operations, ONLY if you are aggregating immediately after.

For example, something like this only takes two operations:

Screenshot_2024-01-04_210158

Notice there are only two "1"s in the output bubbles, even though the input is an array of 5 items?

3 Likes

Thanks for letting me know!

Did you mean aren’t aggregating there?

No, you must aggregate otherwise the subsequent modules consume one operation per bundle (i.e.: 5 instead of 1)

Aggregating the bundles immediately only outputs a single bundle, so only one operation is used.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module.

Other types of aggregators include “Numeric aggregator”, “Text aggregator”, “Create CSV”, “Create Archive”, “Create JSON”, etc.

If you want to learn more about Make, you can read up in the Help Center. I also recommend doing the tutorials in the Make Academy, and learn advanced skills like how to make custom apps to any API in the Make Partner Training Portal - both have certificates for successful completion.

3 Likes