arraysjsonpower-automate-desktop

Power Automate Desktop - convert json array into...anything?


I am building a PAD flow that uses an API call that outputs a json array.

Json sample:

{
    "record_count": 110,
    "reports": [
        {
            "id": 432,
            "name": "Customer Schedule - customer1",
            "group_id": 26,
            "group_name": "Customer Schedules",
            "type": 0,
            "datasource_id": 0,
            "restrictaccess": false,
            "systemreportid": 0,
            "canbeaccessedbyallusers": false,
            "_canupdate": true,
            "apiquery_id": 0
        },
        {
            "id": 433,
            "name": "Customer Schedule - customer2",
            "group_id": 26,
            "group_name": "Customer Schedules",
            "type": 0,
            "datasource_id": 0,
            "restrictaccess": false,
            "systemreportid": 0,
            "canbeaccessedbyallusers": false,
            "_canupdate": true,
            "apiquery_id": 0
        },
    ]
}

(And so on. Note, the number of objects is variable. This is from the API of HaloPSA)

I'm trying to extract the "name" object from the reports array to build a list and cannot work out how to do it. I've tried things like converting the json into a custom object, passing the output into a data table first and all sorts, but everything I've tried just enters the whole json as a single element.

This is the current version of the flow: enter image description here

Which creates the list looking like this: enter image description here

I realise I'll have to set up a loop to iterate through the array to get all the objects, but I can't work out out to just get one in the first instance.

How can I parse the json to extract a specific set of objects as a list?


Solution

  • Typically, after days of trying, I worked it out myself minutes after asking this question.

    Convert the json to a custom object, create a new list, create a variable to represent the array index with an initial value of 0. Then loop through the custom object, incrementing the index variable by one each time.

    enter image description here