How to create an array from JSON objects using Power Automate?

This Power Automate tutorial explains how to create an array from JSON objects using Power Automate.

Here we will learn how to get the selected or interested data from the JSON object and Store the selected data values in an array using the Power Automate flow.

For example, in the screenshot below, you can see that I have selected only the Name value from the JSON object and stored it as an array using a flow.

how to create an array from JSON objects using Power Automate

Create an array from JSON objects using Power Automate

Follow the below steps to build a flow and create an array from JSON using Power Automate.

Let us see how to create an array from JSON object data using Power Automate flow.

Step:1

Create an instant cloud flow, enter the flow name, select the manually trigger a flow action, and click the create button.

create an array from JSON objects using Power Automate

Step:2

Select the +New step and add an Initialize variable action of type array, that we will use later in our flow.

create an array from JSON objects using Power Automate

Step:3

Add a compose action and pass the JSON object data values below as Input.

{
"Customers": [
  {
    "Name": "Richard",
    "CustomerCode": "58244",
    "CustomerLocation": "France",
    "ContactNumber": 7894561230
  },
  {
    "Name": "Noah",
    "CustomerCode": "14789",
    "CustomerLocation": "Mexico",
    "ContactNumber": 8456789620
  },
  {
    "Name": "Jordan",
    "CustomerCode": "21456",
    "CustomerLocation": "Germany",
    "ContactNumber": 7584963210
  },
  {
    "Name": "Rufus",
    "CustomerCode": "25896",
    "CustomerLocation": "Canada",
    "ContactNumber": 8457962130
  },
  {
    "Name": "Rachel",
    "CustomerCode": "19835",
    "CustomerLocation": "USA",
    "ContactNumber": 8302165479
  }
]}
Create an array from JSON objects using Power Automate

Step:4

  • Add a Parse JSON action in the content and pass the dynamic content value of the Outputs of the previous compose action.
  • In the Schema, choose Generate from the sample, pass the JSON object value, and choose Done. It will automatically generate the JSON schema as below:
create an array from JSON objects using Power Automate

Step:5

Select the +New step, add an apply to each action from action triggers, and pass the dynamic content value of Customers from the Outputs of Parse JSON object.

Create an array from JSON objects using Power Automate flow
  • Now select Append to array variable action select the initialized array variable(CustomerDetails) from the dropdown, and pass the values in the Values section.
  • Here we will pass values of Name, Customer Code, and Customer Location from the Outputs of the Parse JSON object.
create an array from JSON objects using Power Automate

Add a compose action and pass the dynamic content variable value to see the output of the selected values in an array format.

create an array from JSON objects using Power Automate

Step:6

Save the flow. Run the flow by selecting the Run flow option. Once the flow ran successfully.

Power Automate create an array from JSON objects

We can see the expected result value of Name, Customer Code, and Customer Location in an array format Output of the compose action.

Power Automate create an array from JSON objects

This is how to create an array from JSON object data using Power Automate flow.

Conclusion

In this Power Automate tutorial, we have learned how to create an array from JSON objects using Power Automate or Microsoft Flow.

You may also like:

>