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
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

Users online (1,529)