cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zeeshansaeed
Frequent Visitor

Extract data from nested json array / meta_data

Hi guys,

 

i have got the below Json result, and i want to extract order_no and deliverydate for each order using power automate.

i can do order_no easily but i  am unable to figure out how can i extract delivery_date

 

 

 

 

{
        "order_no": 1121,
        "status": "completed",
		  
		  "meta_data": [
 
						{
							 "id": 93323,
							 "key": "delivery_type",
							 "value": "delivery"
						},
						
						{
							 "id": 93350,
							 "key": "delivery_notes",
							 "value": "test note"
						},
						
						{
							 "id": 93324,
							 "key": "delivery_date",
							 "value": "2022-01-29"
						},
						{
							 "id": 93325,
							 "key": "delivery_details_timestamp",
							 "value": "1643374800"
						}
				
					],
				
				
				
        "order_no": 1125,
        "status": "completed",
		  
		  "meta_data": [
 
						{
							 "id": 93326,
							 "key": "delivery_type",
							 "value": "delivery"
						},
						{
							 "id": 93328,
							 "key": "delivery_date",
							 "value": "2022-01-30"
						},
						{
							 "id": 93329,
							 "key": "delivery_details_timestamp",
							 "value": "1643374800"
						}
				
					]


}

 

 

 

Appreciate any help one this.

 


Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

I had to format your sample data as a JSON array in order to extract the order_no and delivery_date properties:

 

 

[
  {
    "order_no": 1121,
    "status": "completed",
    "meta_data": [
      {
        "id": 93323,
        "key": "delivery_type",
        "value": "delivery"
      },
      {
        "id": 93350,
        "key": "delivery_notes",
        "value": "test note"
      },
      {
        "id": 93324,
        "key": "delivery_date",
        "value": "2022-01-29"
      },
      {
        "id": 93325,
        "key": "delivery_details_timestamp",
        "value": "1643374800"
      }
    ]
  },
  {
    "order_no": 1125,
    "status": "completed",
    "meta_data": [
      {
        "id": 93326,
        "key": "delivery_type",
        "value": "delivery"
      },
      {
        "id": 93328,
        "key": "delivery_date",
        "value": "2022-01-30"
      },
      {
        "id": 93329,
        "key": "delivery_details_timestamp",
        "value": "1643374800"
      }
    ]
  }
]

 

 

 

This is the demo flow I tried:

Snag_165a2a0.png

I used an array variable to store the JSON array::

Snag_165eca9.png

I used an Apply to each loop to iterate through all the orders (the sample data has two orders). The expressions used in the flow are shown below:

Snag_17befac.png

Snag_163034d.png

 

The expression in the final compose action will get the data we "extracted" from the loop (using Pieter’s method) :

Snag_16abd44.png

This is the runtime output, showing the output of the Compose action:

 

[
    {
        "order_no": 1121,
        "delivery_date": "2022-01-29"
    },
    {
        "order_no": 1125,
        "delivery_date": "2022-01-30"
    }
]

 

 

 

Hope this helps.

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
ekarim2020
Super User
Super User

I had to format your sample data as a JSON array in order to extract the order_no and delivery_date properties:

 

 

[
  {
    "order_no": 1121,
    "status": "completed",
    "meta_data": [
      {
        "id": 93323,
        "key": "delivery_type",
        "value": "delivery"
      },
      {
        "id": 93350,
        "key": "delivery_notes",
        "value": "test note"
      },
      {
        "id": 93324,
        "key": "delivery_date",
        "value": "2022-01-29"
      },
      {
        "id": 93325,
        "key": "delivery_details_timestamp",
        "value": "1643374800"
      }
    ]
  },
  {
    "order_no": 1125,
    "status": "completed",
    "meta_data": [
      {
        "id": 93326,
        "key": "delivery_type",
        "value": "delivery"
      },
      {
        "id": 93328,
        "key": "delivery_date",
        "value": "2022-01-30"
      },
      {
        "id": 93329,
        "key": "delivery_details_timestamp",
        "value": "1643374800"
      }
    ]
  }
]

 

 

 

This is the demo flow I tried:

Snag_165a2a0.png

I used an array variable to store the JSON array::

Snag_165eca9.png

I used an Apply to each loop to iterate through all the orders (the sample data has two orders). The expressions used in the flow are shown below:

Snag_17befac.png

Snag_163034d.png

 

The expression in the final compose action will get the data we "extracted" from the loop (using Pieter’s method) :

Snag_16abd44.png

This is the runtime output, showing the output of the Compose action:

 

[
    {
        "order_no": 1121,
        "delivery_date": "2022-01-29"
    },
    {
        "order_no": 1125,
        "delivery_date": "2022-01-30"
    }
]

 

 

 

Hope this helps.

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Spot-on thanks Ellis 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (4,525)