Extracting multiple arrays from an object

I have a json object and I am trying to extract all the dates from all the slots and I am having issues figuring this out.

they dont need to be mappable individually, I only need them all in one field, comma delimited is fine.

I have tried the map function, the get function and a bunch of others but I can not seem to figure this one out.

The collections that are dates ( with the slots array inside) will always be labeled differently, but there will always be 4 of them.

Hey Cameron,

you can try the join() function and turn the arrays in comma separated lists. Or an Iterator module followed by a Text Aggregator module, this will do the same as well.

thank you for the response!

I think the issue is there are multiple “slots” arrays each inside their own unique collection, inside the main “data” collection.

I am not able to map or join or iterate because the names and amounts of these collection will change every day, also there are multiple “slots” arrays I need to compile into one.

This solution you posted works for one array but there are currently 3 arrays and the collection “2025-03-12” will not exist tomorrow



so even if I branched to 3 separate iterations it will break as the days change

If you are worried about the collection names changing, you can specify each array using their index in the Data collection like:


for the 1st. index etc.

Using a repeater bore the iterator module:

will allow you to iterate through the 4 collections:

Which you can then aggregate, specifying the repeater as the source

Thanks for the reply Harvey.
This does not seem to return anything, all the slots arrays are called slots they don’t have an identifier.

The join function is much better, this screenshot is doing exactly what I want, but again the issue is the mappings will change every day because of the collection names.

If I could use your get solution inside each join it would work but its not returning anything for 1.sots

If you convert Data to an array using get(toArray(get(toArray({{56.Data}}); i)); 2) does the issue go away? (where i denotes 1-4)

just a workaround by converting collections to arrays to use index notation; hence the 2 index at the end as 1 would get the date again

2 Likes

well (get({{1.Data}};1.slots)) returns empty,
so toArray(get({{1.Data}};1.slots)) throws an error that nothing exists toarray

I tried
get(toArray(56.data); “1.slots”) and it returns empty as well

Awesome man, pretty much just recreates with a static path I can use to join!
Now I just need to account for missing collections as sometimes there are 2 or 3 instead of 4 but i think I should be able to figure that out.

Thanks again!




After more testing this actually works with one get

{{get(toArray(56.data); 1)}}
image

It creates a static variable I can map in the next module, and if the slot is empty it just returns empty so it will work no matter what the collections are called and no matter how many collections there are.

Thanks again Harvey!

There might be a better way to do this. Are you using the HTTP module by any chance, if not, could you provide the output bundle of the above?

If you need further assistance, please provide the following:

  • output bundles of each of the relevant modules by running the scenario (you can also get this without re-running your scenario from the History tab).

Click on the white speech bubbles on the top-right of each module and select “Download input/output bundles”.

A. Upload as a Text File

Save each bundle contents in a plain text editor (without formatting) as a bundle.txt file.

You can upload the file here by clicking on this button:

B. Insert as Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles.
These are the two ways to format text so that it won’t be modified by the forum:

  • Method 1: Type code block manually

    Add three backticks ``` before and after the content/bundle, like this:

    ```
    content goes here
    ```

  • Method 2. Highlight and click the format button in the editor

Providing the input/output bundles will allow others to replicate what is going on in the scenario, especially if there are complex data structures (nested arrays and collections) or if external services are involved.

This will allow others to better assist you. Thanks!