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 / How to Extract Data Fr...
Power Automate
Unanswered

How to Extract Data From The Value of Object in JSON

(0) ShareShare
ReportReport
Posted on by 10

Hello Power Automate Community,

 

I am quite new in MS. Power Automate. I would like to extract particular data in the value of object of the array from JSON  

Basically, I need to extract the specific data from the value of object which starts with "project_description" in JSON.

To be more clear, I have to get the value corresponding to "text", which is "XYZ" in this example.

Long story short, i need to get the value "XYZ". 

 

Could you please help me out about this?

here is the sample data:

 

"projects": [
{
"project_id": 9,
"project_name": "Language processing",

"project_description": "{\"blocks\":[{\"key\":\"dopmg\",\"text\":\"XYZ\",\"type\":\"sharp\",\"depth\":5,\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}",

}

]

 

 

Thank you in advance for your help. 

Happy automation.

Categories:
I have the same question (0)
  • VictorIvanidze Profile Picture
    13,073 on at

    Could you show your flow?

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    I'm assuming your projects array is contained within another object. The flow below also assumes you have a single project in your projects array. If you can have multiple projects, then we would need to adjust the flow to accommodate.

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_0-1672671903701.png

     

    Data is a Compose that contains your sample data. Note that I had to wrap it within an object for it to be valid JSON. Also removed the last comma at the end of your project_description which was also invalid.

    {
     "projects": [
     {
     "project_id": 9,
     "project_name": "Language processing",
     "project_description": "{\"blocks\":[{\"key\":\"dopmg\",\"text\":\"XYZ\",\"type\":\"sharp\",\"depth\":5,\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"
     }
     ]
    }

    grantjenkins_1-1672672039671.png

     

    JSON is a Compose that converts the value (object) of project_description to valid JSON. The expression used is below. Note that we use 0 to get the first project. If you had more projects, we'd likely need a different approach.

    json(outputs('Data')?['projects'][0]?['project_description'])

    grantjenkins_2-1672672174105.png

     

    This would give us the following output.

    {
     "blocks": [
     {
     "key": "dopmg",
     "text": "XYZ",
     "type": "sharp",
     "depth": 5,
     "entityRanges": [],
     "data": {}
     }
     ],
     "entityMap": {}
    }

     

    Compose uses the following expression to extract the text from the first object in the blocks array. Note that if you have multiple block objects you would likely go with a slightly different approach.

    outputs('JSON')?['blocks'][0]?['text']

    grantjenkins_3-1672672350196.png

     

    The result from the Compose would be:

    grantjenkins_4-1672672399540.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • HalimeArs Profile Picture
    10 on at

    Hi @grantjenkins,

     

    Perfect! It works very well. Thanks a lot. 

  • SwJ23 Profile Picture
    85 on at

    I realize that a very good answer has been given, but I'd just like to point out (because I'm learning about Power Automate and object-oriented programming too, and this was a revelation to me) that you have posted the text for an Array of Objects. This language should be helpful when searching for similar answers.

     

    In JSON, everything is an Object initially, so I'm guessing you didn't copy over the initial curly braces. So what you really have is an Object containing an Array of Objects. You access an Object's properties (and sub properties) in Power Automate by something like this:

     

    outputs('Name_of_Connector')?['Property_Name'][arrayintegerifnecessary]?['Subproperty_Name'] etc. The "?" shows the downward connection of objects and properties, which can be linked together, and when you put "[ ]" at the end of a property you're accessing that index of an array.

     

    <---- this curly brace starts any JSON 

         "projects": [ <---- this open bracket indicates that "projects" is an array
              { <---- this open curly brace indicates the following text is an object
                 "project_id": 9, <---- this is the first Object property, which is an integer
                 "project_name": "Language processing", <---- this is the second Object property, which is a string

                 "project_description": 

                      "{\"blocks\":[{\"key\":\"dopmg\",\"text\":\"XYZ\",\"type\":\"sharp\",\"depth\":5,\"entityRanges\":[],\"data\":

                      {}}],\"entityMap\":{}}", <---- this is also a string, though it looks to be an array of objects that has been turned    

                                                                  into a string)

    }

    ]

    } <---- this curly brace is at the close of any JSON

     

     

     

    So, if a connector named "Compose_2" contained your JSON, you could access "project_id" with this text:

     

    outputs('Compose_2')?['projects'][0]?['project_id']

     

    And using the json() function to convert your Object's index-0-Array's Object's third string-Property, as @grantjenkins demonstrated, you could access XYZ like this:

     

    json(outputs('Compose_2')?['projects'][0]?['project_description'])?['blocks'][0]?['text']

     

     

    Getting the gist of all that helps immensely when plinking around in Power Automate.

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard