Map An Array With "Nested Array Contains X" Filter

If I have an array like:

{
    "Available": [
        {
            "id": "f641c5bb-0e2b-4391-b311-9e60751b1cca",
            "qualifications": [
                "Training"
            ]
        },
        {
            "id": "77e8aebf-28fd-4906-b602-353fbd40b298",
            "qualifications": [
                "Game Master",
                "Training"
            ]
        },
        {
            "id": "100a3a3e-3bce-4bf1-960e-129ceb3f5676",
            "qualifications": [
                "Game Master",
                "Performance"
            ]
        },
        {
            "id": "ec3ee631-c822-4bf8-bd11-899a3f3c20d6",
            "qualifications": [
                "Training"
            ]
        },
        {
            "id": "4243d471-47c0-414c-88b7-5a948418acc7",
            "qualifications": [
                "Performance"
            ]
        },
        {
            "id": "827b4ad7-26e8-428b-b3df-da537c1b42b4",
            "qualifications": [
                "Training"
            ]
        },
        {
            "id": "13b66ae2-723e-442f-9ca5-19fd152a6033",
            "qualifications": [
                "Game Master"
            ]
        },
        {
            "id": "3a06d885-22b2-48ed-881b-ae096d725b07",
            "qualifications": [
                "Game Master",
                "Performance"
            ]
        }
    ]
}

How can I fetch all of the IDs of items in the array whose qualifications array contains ā€œGame Masterā€?

{{map(1.Available; "id"; "qualifications"; "Game Master")}} seems to work but only if the qualifications array only includes 1 item which is Game Master and doesnā€™t work if the qualifications array contains any other items.

Iā€™m trying to do this in a map function to avoid wasting operations, as I need to extract 6 sets of these IDs. The fact that this filter works in some scenarios makes me optimistic that this will be possibleā€¦

I do have some control over the structure of the data but I also need to be able to count the number of items in the array whose qualifications array contain certain values so this is the structure that Iā€™ve landed on.

Simple blueprint for testing - blueprint (20).json (5.3 KB)

Hi I was able to do it and took one extra operation.



Here is the blueprint
blueprint (23).json (9.0 KB)

1 Like

Thanks for this but as I mentioned, I need to extract six sets of IDs here (e.g. the IDs for the items that have ā€˜Trainingā€™ qualifications) so if I used that approach then Iā€™d have to add a router and the iterator + array aggregator combo for each set, store the extracted IDs in a variable and get the variables once Iā€™d extracted all of the IDs. Thatā€™s what Iā€™m trying to avoid.

1 Like

Got it this way it is more hacky and it depends on the Game Master being the first qualification in the Array which right now in every time it shows up it is. You could probably use sort to make this more robust. But right now with the qualifications you gave as example it works.

{{map(1.Available; ā€œidā€; ā€œqualifications.1ā€; ā€œGame Masterā€)}}

1 Like

Thanks! Iā€™ll try this tomorrow and get back to you.

Just thinking this through though, the array will be a variable length list of the qualifications though so I donā€™t think Iā€™ll be able to rely on certain qualifications being at a certain index unfortunately.

1 Like

Iā€™ve just tried this an unfortunately it wonā€™t work for me, as I canā€™t rely on the length or order of the items in the array being consistent.

I think I have a solution thoughā€¦