Understanding how to use JSON with Power Automate

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi my name is Jonathan Silva welcome to another episode of my power automate Basics series for today's episode what we're going to take a look at is how we can utilize Json within power automate really the big picture is understanding what is Json if you are very new to power automate and why we need to be able to parse out Json objects in order to use those in further actions throughout the flow so let's jump into Power automate and take a look thank you all right so what you see on screen here is all I've done was set up a flow with a manual trigger and just a compose data operation now inside of that compose data operation step here I've added in a very small very basic Json array now the way that we work with our Json is we are writing out a this JavaScript object notation to be able to identify arrays collections items to be able to use throughout the process of moving our data Json is really useful here because it allows us to very you know easily see the data and understand how we can utilize it within other actions within our flow and power automate now what I'd like to do here is to show you the different pieces of our Json array by just going ahead and testing this to see how this actually shows up when the array is passed through so we're going to do our manual test here all right so let's take a look at the output from that array and here you see the input is located like this and there is our output now the way that this works is we work within our Json is everything within our curly braces here would represent the actual array that we are working with and each and every single one of these are separate objects within that array think of these objects as columns on a table right sometimes when we're working with specific actions in power automate we are returning all the objects on a table except we're not able to actually utilize them well looking at the Json here you can see what those objects are and these are going to be your header names of your columns so we have name company and lucky number here now along with the names of the column here and the way that this is describes it is a name value pair so this section here we have the name the next bit we will have here within my first name my company name and there is my lucky number will be the value of that pair think of this as what is actually being returned as far as the maybe the cell within the column itself if you're pulling from a full table and what we're going to utilize in this case is the ability to extract the individual objects or the name value pairs to be able to utilize and place them inside of actions later on now in this case we're just writing a very small array here to take each one of those pieces as Dynamic content but in some cases we may need to use uh parse Json or be able to app you know capture each individual item when it's just not available as an output when we want to work with it so let's take a look at what I mean by that what I'm first going to do is copy this out because it's nice to have this on hand as we try to extract the individual values then I'm going to select edit here and just for the sake of argument I'm going to click new step and if I send a new have a new step to send an email let's say I want to send an email to myself with just the the objects the those fields there that I've just placed in I can come here to the body of my email and if I look at my Dynamic content that does pop up you'll see that I just have the entire output I don't have the ability to call to each one of the specific objects like name company and lucky number to be able to place here inside of this email and if that's ever the case where you're pulling in a table of data or you're pulling in objects that you're trying to utilize and you can't actually capture them you can't use them as Dynamic content the step that you you need to implement here is the step called parse Json and what this data operation does of parse Json allows us to use the Json from a previous action and to be able to identify the individual objects that can be utilized as Dynamic content so what we need to First do is pass in okay what is the content that we want to parse out or split up so we're going to use the output from this compose and the schema that we want to use in order to identify what the objects are is going to be whatever we copied out earlier now I could copy it from here as well so I'm going to select generate from sample and paste in what I've copied there so it looks just like that now when I select done what you'll notice is this parse Json action looks at the array that's passed in and starts to identify what is inside of it so in this case we have an object we have multiple objects and the properties of those objects we have a name which is a string value we have company which is another string or text value and then we also have lucky number which is a data type of an integer now it's automatically detecting that one of the key Parts about working with Json anytime you are working with a string like the name here for the value itself it must have our quotation marks there to identify that it is a string value for something like an integer or a number you can see that we do not need those quotations there and it identifies it just fine but now that we have our parse Json added in here what you can notice is if I come back to this send an email I can go ahead and click into my body here and now we can see some of the outputs from our parse Json in this case I'm going to go ahead and send an email to myself with just a bit of a message just kind of my you know putting in some of this data here so I'm going to go here and send an email itself in there I will put my subject here is take a look at this Json I wrote and I can come in here and say uh hi my name is and I can put in my name my Dynamic content and I work at and I can put in my company and then I can say my lucky number is and add that in but what you'll notice is sometimes within the parse Json we're looking for the outputs there of the specific values and they're just not available and that just happens to be a lot of time based upon the action you're trying to utilize that with or the part of the action in the field in which you're trying to import that all right embed that into you'll notice the lucky number is not here but if I do click up here into the subject well there it is and that just happens to be because of the way this send an email action is set up so there is a way around that I can do this I'm gonna go ahead and put a space here real quick and just add in my lucky number into my subject and a bit of a trick here is I can copy this out by clicking and dragging over and highlighting my Dynamic content I can go ahead and copy it there and then because of the way that power automate works is it's treating Dynamic content as like a general text field so I can just go ahead and paste that there into the body of my message and so it actually is identifying that you can see here that is the actual field it's looking at the body from the parse Json identifying that specific uh name value pair the lucky number and I can just remove it from up here and now all I have left is let's go send that email and take a look at what I get in return so I'm going to hit save and then go ahead and do our test here's the test all right so my flow has run successfully here it's quite small and just a little simple to just describe and explain how json's working but you can see here is the email that I generated hi my name is Jonathan I work at pragmatic Works my lucky number is nine well let's take a look at the actual email itself so I'll go ahead and pull that up and here you are there is the email that I generated that has all of the information that I've pulled out from the Json array so we're now able to capture that Json that was written there in that compose and utilize the dynamic content that we're creating with the parse Json data operation now you might be saying well that's you just written Json there you copied and pasted when am I ever going to do that in the real world well there may be many other actions that you're using within your flow and power automate that is generating an output but it's coming in as a full array rather than the ability to extract individual fields or columns from that are right understanding that we have the ability to actually find them once you see the output usage there's the array but I want that one little piece utilizing parse Json is the best way forward it's the easiest way for you to go ahead and capture that individual object from the Json array to use it as your Dynamic content now I will say in some cases you'll see there's an array inside inside of an array right you'll have a collection or you might have a subset within your array so you may actually need to go in and do that parse Json again from that output from that one piece on the object to find the sub categories within it and then you'll be able to find it from there it does take a little bit of massaging getting you down to that that lower granular level but you will be able to finally get there and use that as Dynamic content inside of your flow thanks for joining me again here within our power automate basic series I think understanding how to work with and use Json is such a strong uh skill set to build within power automate because once you understand Json and how it's used here everything else becomes a lot easier within troubleshooting with error handling and just really understanding how you can get to those granular values each and every single time stay tuned for future episodes here within our power automate Basics I'm excited to see you there thank you foreign thank you
Info
Channel: Pragmatic Works
Views: 5,915
Rating: undefined out of 5
Keywords: parse json power automate, Power automate, parse JSON, Flow, Power automate select, JSON, array, power platform, power automate array, power automate object, power automate collection, JSON collection, power automate json, power automate write json, compose, power automate flow how to parse json, microsoft flow tutorial, process automation tools, demo, example, Jonathon Silva, Pragmatic Works, learn
Id: Ls_Fj3qjeJ4
Channel Id: undefined
Length: 11min 35sec (695 seconds)
Published: Fri Mar 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.