web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Parse json that has ob...
Power Automate
Unanswered

Parse json that has objects and array and extract a value

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, Below is the json schema i am using in my Parse json connection & Json body sample. The parse works with the schema below , but i am unable to extract the addressPrefixes by name. 

 

E.g I need to parse the json and get the addressPrefixes under a property with name : VM1 . 

 

How to acheive this using power automate.

 

{
    "type""object",
    "properties": {
        "statusCode": {
            "type""integer"
        },
        "headers": {
            "type""object",
            "properties": {
                "Cache-Control": {
                    "type""string"
                },
                "Pragma": {
                    "type""string"
                },
                "Transfer-Encoding": {
                    "type""string"
                },
                "Vary": {
                    "type""string"
                },
                "x-ms-request-id": {
                    "type""string"
                },
                "x-ms-correlation-request-id": {
                    "type""string"
                },
                "x-ms-arm-service-request-id": {
                    "type""string"
                },
                "Strict-Transport-Security": {
                    "type""string"
                },
                "Server": {
                    "type""string"
                },
                "x-ms-ratelimit-remaining-subscription-reads": {
                    "type""string"
                },
                "x-ms-routing-request-id": {
                    "type""string"
                },
                "X-Content-Type-Options": {
                    "type""string"
                },
                "Date": {
                    "type""string"
                },
                "Content-Type": {
                    "type""string"
                },
                "Expires": {
                    "type""string"
                }
            }
        },
        "body": {
            "type""object",
            "properties": {
                "name": {
                    "type""string"
                },
                "id": {
                    "type""string"
                },
                "type": {
                    "type""string"
                },
                "changeNumber": {
                    "type""string"
                },
                "cloud": {
                    "type""string"
                },
                "values": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "name": {
                                "type""string"
                            },
                            "id": {
                                "type""string"
                            },
                            "serviceTagChangeNumber": {
                                "type""string"
                            },
                            "properties": {
                                "type""object",
                                "properties": {
                                    "changeNumber": {
                                        "type""string"
                                    },
                                    "region": {
                                        "type""string"
                                    },
                                    "state": {
                                        "type""string"
                                    },
                                    "networkFeatures": {
                                        "type""array",
                                        "items": {
                                            "type""string"
                                        }
                                    },
                                    "systemService": {
                                        "type""string"
                                    },
                                    "addressPrefixes": {
                                        "type""array",
                                        "items": {
                                            "type""string"
                                        }
                                    }
                                }
                            }
                        },
                        "required": [
                            "name",
                            "id",
                            "serviceTagChangeNumber",
                            "properties"
                        ]
                    }
                },
                "nextLink": {
                    "type""string"
                }
            }
        }
    }
}
 
My Json looks like below
 
{
      "name": "VM01",
      "id": "VM01",
      "properties": {
        "changeNumber": 1,
        "region": "USWest",
        "regionId": 3,
        "platform": "Azure",
        "systemService": "VM",
        "addressPrefixes": [
          "xx.xx.xx.xx/32",
          "xx.xx.xx.xx/32"
        ],
        "networkFeatures": null
      }
    },
    {
      "name": "VM02",
      "id": "VM02",
      "properties": {
        "changeNumber": 2,
        "region": "USEast",
        "regionId": 4,
        "platform": "Azure",
        "systemService": "VM",
        "addressPrefixes": [
        "xx.xx.xx.xx/32",
          "xx.xx.xx.xx/32"
        ],
        "networkFeatures": null
      }
    }
Categories:
I have the same question (0)
  • harpalrana Profile Picture
    17 on at

    I tried the same in my test tenant and I am able to find it

    Screenshot 2023-08-11 002350.png

  • dsab81 Profile Picture
    Microsoft Employee on at

    @harpalrana I get below when i tried above :

     

    1. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['values']' is of type 'Null'. The result must be a valid array.

     

    2. Even if it works, i need to loop through each object in Json by 'Name' (e.g. When Name starts with VM) and if matches, then get me the Name and its addressprefix

     

    dsab81_2-1691700039280.png

    Output :

    dsab81_1-1691699587855.png

     

    You can download the json i am using from https://www.microsoft.com/en-gb/download/details.aspx?id=41653

     

  • SamLed Profile Picture
    2,338 Moderator on at

    Hi dsab81,

     

    PA propose dynamic contents according to the provided schema in Parse JSON.

    You have to check raw output of your Get content action, I guess there is no "values" property.

     

    I made a test putting raw output of an action in a compose one, generated schema from this output and renamed existing "values" property to "value". Parse JSON didn't complained but "Apply to each" obviously didn't found 

    body('Parse_JSON')?['body']?['values'] while it did before renaming.

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

     
  • dsab81 Profile Picture
    Microsoft Employee on at

    @SamLed would you mind sharing a screenshot of your flow after changes?

  • dsab81 Profile Picture
    Microsoft Employee on at

    When i updated values to value , i still get this .

    The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['value']' is of type 'Null'. The result must be a valid array.

     

    dsab81_0-1692040679399.png

     

  • SamLed Profile Picture
    2,338 Moderator on at

    Hi,

     

    Show me your output JSON, you post schema and sample of items from JSON, but I need the beginning of your JSON, from start to first item.

  • Verified answer
    dsab81 Profile Picture
    Microsoft Employee on at

    @SamLed Thanks for getting back. My issue is fixed. below one did the trick. Didnt had to update 'values' as well.

    outputs('Parse_JSON')?['body']?['values']

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard