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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How do I get a propert...
Power Automate
Answered

How do I get a property from a JSON object?

(1) ShareShare
ReportReport
Posted on by 13
Hi there, 
 
I am pretty new to Power Automate. 
 
I have this JSON response from an API call. It is an object of objects.
 
{
  "created_at": "2025-02-24 09:20:30",
  "status": "ACTIVE",
  "new": "0",
  "flag": "0",
  "notes": "",
  "updated_at": "2025-02-24 09:20:30",
  "answers": {
    "157": {
      "name": "OK",
      "order": "14",
      "text": "Are you OK to answer this question?",
      "type": "ctl_radio",
      "answer": "No"
    },
    "158": {
      "name": "submission",
      "order": "1",
      "sublabels": "{\"day\":\"Day\",\"hour\":\"Hour\",\"last\":\"Last\",\"litemode\":\"Date\",\"minutes\":\"Minutes\",\"month\":\"Month\",\"year\":\"Year\"}",
      "text": "Submission",
      "timeFormat": "24 Hour",
      "type": "control_datetime"
    },
    "150": {
      "name": "date",
      "order": "5",
      "sublabels": "{\"day\":\"Day\",\"month\":\"Month\",\"year\":\"Year\",\"last\":\"Last Name\",\"hour\":\"Hour\",\"minutes\":\"Minutes\",\"litemode\":\"Date\"}",
      "text": "Date",
      "timeFormat": "AM/PM",
      "type": "control_datetime",
      "answer": {
        "month": "02",
        "day": "23",
        "year": "2025",
        "datetime": "2025-02-23 00:00:00"
      },
      "FormattedDate": "02-23-2025"
    }
  }
}
 
How can I get just the 'FormattedDate' part in a Compose action using an expression (or anything)? 
 
The reason I am struggling is that whilst "FormattedDate" is always within the final object of the response, the title of this object (e.g. "150" in the above) will change. The only constants to work with are that the text property will always be "Date" and the name property will always be "date". 
 
Is there anyway to get this value? I am looking to simply extract it as a string in a Compose action, and I can format it later on from there. 
 
Cheers very much
BC Jabra.
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    rzaneti Profile Picture
    4,476 Super User 2026 Season 1 on at
     
    For the specific example, you can use an expression like [your_json_outputs]['150']['FormattedDate'], but I believe you already know about it :)
     
    To solve your problem, you would need to first retrieve the last key from a JSON object, so you can use it as a substitute for the 150 in the expression above. There is not a built-in function or action to retrieve the last key, but you can use a workaround with the xpath function. In this blog, you can find a step-by-step to retrieve all keys from a JSON object: https://digitalmill.net/2024/10/03/extracting-json-object-keys-in-power-automate/
     
    Then you can reference the last one by using the last() function. Finally, your ideal expression may look like: [your_json_outputs][last([lkeys_arr])]['FormattedDate'], where the dynamic content of the array generated from the object keys corresponds to the text in red.
     
    If the instructions are not clear enough, I will be happy to provide you further guidance. 
     
    Let me know if it works for you or if you need any additional help!
     
    If this is the answer to your question, please mark the post as Accepted Answer.
    If this answer helps you in any way, please give it a like.

    Check more Power Platform content on my website.
    Lets connect on LinkedIn.
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,963 Moderator on at
     
    A very simple way is to extract it directly using a few expressions in your compose. I am showing you this as it will also help you in other areas besides this, as a lesson.
     
    1. I have your Object (and copied yours out)
    2. I add a Compose
    I use the following to get the date value itself.
    split(split(trim(string(variables('JsonData'))),'"FormattedDate":"')[1], '"}')[0]
    now let me explain it.
    --I have a Variable (object) I created in my flow and pasted in your data. I called the Variable JsonData.
    ----Next, I have to use the string and trim functions to change the object into a string and to remove all spaces as you see below
    {"created_at":"2025-02-24 09:20:30","status":"ACTIVE","new":"0","flag":"0","notes":"","updated_at":"2025-02-24 09:20:30","answers":{"150":{"name":"date","order":"5","sublabels":"{\"day\":\"Day\",\"month\":\"Month\",\"year\":\"Year\",\"last\":\"Last Name\",\"hour\":\"Hour\",\"minutes\":\"Minutes\",\"litemode\":\"Date\"}","text":"Date","timeFormat":"AM/PM","type":"control_datetime","answer":{"month":"02","day":"23","year":"2025","datetime":"2025-02-23 00:00:00"},"FormattedDate":"02-23-2025"},"157":{"name":"OK","order":"14","text":"Are you OK to answer this question?","type":"ctl_radio","answer":"No"},"158":{"name":"submission","order":"1","sublabels":"{\"day\":\"Day\",\"hour\":\"Hour\",\"last\":\"Last\",\"litemode\":\"Date\",\"minutes\":\"Minutes\",\"month\":\"Month\",\"year\":\"Year\"}","text":"Submission","timeFormat":"24 Hour","type":"control_datetime"}}}
     
    ----Next, I use split to take the full string and turn it into 2 halves, by splitting by 
    "FormattedDate":" and I use the [1] to tell the Split command, to give me back the 2nd value in the returned split array
    Since split gives an array back, we don't want the front part (aka [0]) we want the back part (aka [1])
     
    ----Next, we take the back part which looks like this
    02-23-2025"},"157":{"name":"OK","order":"14","text":"Are you OK to answer this question?","type":"ctl_radio","answer":"No"},"158":{"name":"submission","order":"1","sublabels":"{\"day\":\"Day\",\"hour\":\"Hour\",\"last\":\"Last\",\"litemode\":\"Date\",\"minutes\":\"Minutes\",\"month\":\"Month\",\"year\":\"Year\"}","text":"Submission","timeFormat":"24 Hour","type":"control_datetime"}}}
     
    You can see 02-23-2025"} at the start.
    well we want to use Split again so that we can get the date value. Use the split function with value "} because its what comes right after the actual date value we want.
     
    So now in the Second split array, we get the Date which sits in the [0] split and then the rest of the object data string is in [1] which we don't care about.
     
    And a visually formatted so it flows with the expressions I showed above
     
     split(
          split(
               trim(
                     string(variables('JsonData'))
                )
          ,'"FormattedDate":"')[1]
    , '"}')[0]
  • Verified answer
    Chriddle Profile Picture
    8,686 Super User 2026 Season 1 on at
    Assuming your JSON is in a Compose, all you need is this simple XPath expression:
    xpath(
    	xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    	'//Item/answers/*[text="Date"]/FormattedDate/text()'
    )
    This returns a list of values. Just take the first one.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 840

#2
Valantis Profile Picture

Valantis 661

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard