Add/ remove/ modify JSON elements of a JSON array in Power Automate/ Microsoft Flow

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Power Automate is like a continuously evolving engine adding more power to it with every release by Microsoft. I still remember the limited functionality it had when it was introduced. Looking back to then and now, it’s been an evolution of Power Platform and Power Automate as well. Not only the name has been changed from Microsoft Flow to Power Automate, even the underlying functionalities have evolved a lot.

And one of them is the capability to work with JSON objects. With the world moving away from SOAP to REST based services, JSON have become the primary format of data exchange between environments.

And here is one such requirrement. Where I needed to Add/ remove and modify the incoming JSON request. So I had an incoming JSON in the following format.

[
    {
       "x_200_fname": "debajit",
       "x_200_lname": "dutta",
       "x_200_trantime": "6/20/2020"
    },
    {
       "x_200_fname": "Gabriel",
       "x_200_lname": "Canata",
       "x_200_trantime": "1/15/2020"
    }
]

As you can see, it’s  a JSON array with three properties in there. No I had few things to do with the array.

  • Change the properties like “x_200_fname” to more readable property like – “firstname. Similarly for “x_200_lname” to lastname and “x_200_trantime” to transactiondate.
  • Add a new property to the JSON called “fullname” which is combination of first name and last name
  • Modify the x_200_trantime to a suitable date format. For example an incoming date in the format 6/20/2020 should be formatted to 6 Jun 2020.

So I will modify the JSON as per the requirements stated above and then pass it on. Understand iterating through the array won’t help here. It is is more of like we get an incoming JSON, modify the JSON properties and then pass the JSON forward to be processed downstream.

Honestly I thought I am going to hit hard luck here. However after lot of searching I got the “Data Operations – Select” from Power Automate.

image

And then I get the wonderful data operation. As you can see, I have created one custom property called fullname. Also have modified the incoming property name and property value as well like the transactiondate.

image

And then when I run the flow, below is the output post select operation. Wonderful isn’t it?

image

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Leave a Reply