in this video we're talking about data transformation and JSON data in NAND let's get into it right now in front of me I have JSON data as the output section here on the right hand side now if you're new to NAND this can be a bit confusing to say the least and we're going to be breaking this down so it's really freaking simple for you the first thing that I want to mention here is that when we're dealing with JSON data we have something called key value pairs now the key is in what it is what is white here okay and this is how we reference data and the value is usually purple it can be green and this is the data that we're referencing and so take a look at this we have these clients here okay we have John Doe as one client we have Jane Smith as another client and we have Mike Johnson as another client now how we can reference these people comes down to the key value pairs now let's take a look we have name here we have name here and we also have name here and this is the crux of essentially more or less how key value pairs work if we're looking to reference somebody's name we're always going to be looking for the key that says name and it's always going to pull out the value of the person's name which is John Doe in one example or it's Jane Smith in another example or it's Mike Johnson so all JSON is is it's just a convenient way that's both human and machine friendly to essentially um yeah just deal with data and uh and all that kind of stuff and so this is more or less it we have key value pairs it's the same thing when we look at email for example or we look at phone and so this is how we can pull out important data now why this matters is because let's say we want to send off an email to all these people well we'd look at the email field here and then we'd pull out this email and what we'd be able to do with that information is then use a Gmail module here for example and I'm just going to connect this in here so you guys can kind of take a look and see what this looks like if I was to send off an email well I need to know who I want to email and so I could easily just pass in Jane Smith's email here and now this is how I can reference in a Gmail module her email which is right here which is pulling in the information here for me to email her and this is more or less the backbone of how N8 works and how JSON data works now of course when it comes to JSON data we can add uh JSON data whenever we want to before I talk about adding it on I just want to mention one more thing here which is if we're actually looking at the key here okay and we look at the value here we notice the value changes first client is John Doe second client is Jane Smith third client is Mike Johnson so we know the value always changes depending on the data so this is a variable field the key always remains the same right because no matter who it is we're referencing John we're referencing somebody potentially well by their key here and so if we were to have let's just say I went in here and I edited this data if I had like email address and then I had email um let's just say email contact okay and I was to try and find the email of John Doe by email which is this field here i would be able to find it if I was to find try and find Jane Smith's email address by email but it's actually in the key email address I would not be able to find it and if I went down to Mike Mike for example here and I was trying to find his email based on the key email I would also not find it because the issue is is that when we're finding things based on a key we're looking for that exact key if there's a single character off like in this instance here right we have email address this is not email this is now something completely different it's not going to work and same thing with here this is also not going to work because we're looking for the key email we're not finding it because it does not exist anymore we have different keys so when you're pulling out data based on the key you always need to make sure that you're pulling in the right key anything that's misspelled in any other way is just not going to work now it's important to note that we can always change these keys at any one time so if we wanted to reference it by email address down here no problem we could come in here we could uh just edit this one more time and we could for example pull in email address so I'm going to update all of the clients based on email address here so we'll do John Doe we'll do Jane Smith and we'll also do Mike Johnson down here save it okay and now when we run this one more time we'll see when we plug this into Gmail here oops when we plug it into Gmail we can't find the email this field doesn't exist anymore because we're trying to find email but now it's marked as email address so this is not going to work it's not going to send the email because we're referencing the wrong key but if we were to update this now it is going to work and so now it works and it pulls in the person's email all that is to say is that keys can change it's just that you don't want every single you don't want every single key to be different or every single time the scenario runs the keys to be different so you can choose the key name here it's just that it has to be consistent across all runs you can't just have this change all the time and so that's important to note now when we talk about creating JSON here there's multiple ways in an end to create it now we can choose the manual mapping which is the easy way or we can choose the JSON structure which is the more advanced way and let's start with the easy way first by manually mapping we can just add a field down below here okay and we can add in whatever field we want so I could be like name equals Jonno Catliff and I could test this step out and it's going to create JSON data for me automatically i could also add another um field here being like country equals Canada and there we go we added more information on here as well and so that's one way of doing things we could also just import in JSON this gets a bit technical and this is you know if if you know JSON which the I would presume you don't because you're watching this video or maybe you just want a quick refresher but you don't need to know JSON is the point that I'm trying to get at here to add this in here all we need to do is know how to ask chat GPT here how to structure this for us our freaking boy ChatgPT has got our back every single time when it comes to structuring uh JSON data so I could just be like "Please create JSON data for me around a client." Um make it simple with their first name last name email phone number and services they're looking for with as many spelling mistakes in there as possible as an extra bonus and uh no matter what Jad GBT will understand it and it'll give us over JSON and we can just copy this and then we can just choose the JSON object and paste it in here test the step and now we have the exact JSON data that we referenced or created in NAD or in chat GPT and we can just go ahead and change this however we want we could do like first underscore name last underscore name and so on and so forth and uh just adjust it however we want so that's creating JSON data and then updating JSON data in NADEN now the cool thing is is that why this could be important to you with the JSON mode is not necessarily because I think most people would come in and create JSON data but a lot of the times when you're testing workflows you just need data like immediately to get the ball rolling and just start testing and and trying to build scenarios and this is a great way just to get your foot off the door so that you know instead of having to always depend on setting up the proper triggers and maybe you come in here and you're like trying to work with some action in an app and you want to do like drive and you let's just say you you create a trigger down here and then you try and connect it in you're like crap like this is going to take me forever i don't want to spend the the 20 minutes to solve this um well you don't have to you can just start off by keeping it super simple and super easy and just you know structure JSON right away in using chatbt in a matter of a couple seconds you're off to the races and you can just build the scenario that you want to build and see if it's even possible and you're getting the results you're looking for without spending this tremendous time investment up front trying to do something that ultimately might not matter at the end of the day and so that's really important i used JSON data for testing purposes all the time just like we saw in this module now the next thing that I want to talk about is the data types in JSON and this is um this is essentially the different options with JSON now what I find interesting about this is that this is where most people kind of drift away and they find this stuff boring but this is probably the most important thing about JSON data i would argue that this is one of the most important things when it comes to actually mastering a platform like NN because if you know this kind of information you're gonna you're going to rock at NN because you're just going to understand how this works if you don't understand how this works you're going to be struggling with NadN for a very very long time until you actually understand what this works so let's break into this we have different data types you're probably familiar with text an example could be somebody's name Jane Doe and you're probably familiar with numbers as well an example could be like a budget of $500 or $5,000 so let's say somebody goes to your website here they fill out a a form inquiring about your services and they put in like their uh budget down here this is a number they put in $5,000 now we have a number that's just like a good example of what it could look like another um another data type and we're going to skip over array here in collection because these are the two most advanced data types and we're going to circle back to it is boolean and you're probably also somewhat familiar with this this is essentially saying "Hey it's either true or false there's one of two options true or false that is it there's nothing else." So take for example on you know social media you can be a verified user and there's one of one of two options it's either you're verified or you're not verified and that's it or for example maybe you have a filter on your website where you're like "Hey is this budget over $1,000 true or false?" In this case it would be true if it was $100 it would be false and so that's more or less boolean data and then dates of course you can have like a date of a form submission so what was the date that somebody filled out this form right here or alternative it could be like the date the birthday it could be a lot of different things and then binary data which we're not going to get too far into in this uh particular video is files and images so you can think about it like a PDF file you can think about it like a PNG image right and then we have effectively collection and you can think about uh collection as like a Google Drive folder it's just an assortment of random things uh or or or whatnot and what I mean by that like one example of that is like um a client so you can have a name for that client being Jane and email equals janexyz.com and their phone number and so on and so forth and yeah it's just an assortment of a bunch of different things like a Google Drive folder where you could just throw in tons of different stuff it could be an assortment of like uh a PNG maybe like resume and then you could have like a Google doc and then you could have like um like a whatever there's just a lot of different things that you can add in here and then an array is a list of the same data type so you could think about it like if somebody's inquiring for services on a website maybe they want DJ services and maybe they want photography services or maybe they want DJ services or videography services and so on and so forth right the most common way of viewing an array and this is super important is like going to the grocery store so maybe you go to the grocery store and you want to buy apples oranges and mangoes this is an array or it's a fancy way of saying or computer jargon way of saying a list and so that's more or less a list right you're going to the store and you want to buy three things and that's all there is to lists these can obviously get a lot more complicated than that but let's kind of break this down because this is really really important if we circle back okay to NADN and we open up this sample data here we can see in the schema here okay we can see different data types so if we were to look very closely we can see that this is an array and we know it's an array because of the object here okay or sorry the the icon here and this is what an array or a list looks like in Naden similarly if we look to JSON the JSON view up top here we can see that it's an array by these square braces and this is important because this is essentially the syntax or just the boilerplate way of arrays there's you just have to memorize this it's kind of like language I guess and learning new words and sometimes you just got to brute force the this kind of information to your memory and more or less this is what an array always looks like and at the you'll always see this square bracket both at the top and also at the bottom here as well right so it's um essentially at the top at the bottom and then it contains everything within it and you know it contains everything within it because we have the client here and this client then has a space between it which is from here to here and then it's everything else is nested within it right we have this nested array and there's this little space in between here and we can see if we went all the way down there's always a space and we can see what's nested or within that array so if we were to take this array down and follow this line we can see that um we still have everything here right so that's just important to note when we're dealing with arrays and so more or less the next thing is that um if we go back to the schema we have objects we can see the object is the box icon in NAD and if we go over to JSON the object is essentially these curly braces same kind of deal that everything is nested from within it so if we look we can see that everything is essentially a line over or a degree of separation apart and if we scroll all the way down along this line we can see that again right everything is within it so we have the start here we have the end here and because this is a list of arrays we have one array which is right here and this is object one and then we have object two down here and then we have object three down here and we again know that these are different objects because we have the start of an object and the end of an object and then the start of another object and this is all within a list because that list can have multiple items within it just like our grocery store if we were to go over to the grocery store for example we have in this list which would have like a square bracket start square bracket end we have three things first apples then oranges then mangoes and so essentially that is a list that is objects we can circle over to the next ones within schema here and we have text which is the a kind of like John Doe we have boolean which is the check mark which is true and so on and so forth all the way down and so that's important to know just because when you're dealing with these different views you want to be able to tell pretty quickly what the what the data type is and so why I think that matters so much is because the way these data types interact is always going to be different so an array is going to interact differently than an object which is going to be different than boolean here which is going to be different than text over here and so the way these play with each other they don't play nicely all the time so let's kind of explore this a bit further here so if I open up my data types module here we're going to take a look at a bunch of different stuff so we have the sample data coming in on the left hand side here is the output let's take a in sorry the input let's take a look at the output on the right side so I'm going to run this test so the first thing is is that we can change data back and forth so we have a key here which I just named object you can name it whatever you want to and effectively this is taking in JSON.client one so that is right here okay and we're taking in an object and we're converting that into string and so essentially if I were to pull up JSON here and we look at what we're pulling in which is right here to right here we're taking this object and then we're converting it into string and we can see that now this is different and this is different because obviously object and text are are different but you know that because we have the classic quotation on the start and on the end and everything in between this is text so we just converted an object here into a text here and now it went from being like an object on the outside to text on the outside and similarly we can do this with other data types as well now the second example I want to get into is essentially this text equals true so if we look at what we have here client number two is active we can see that our client number two is Mike Johnson and is active equals true now this currently is boolean uh data type we know that because we have the checkbox here so this is essentially saying we have a data type of boolean logic and if we switch that into text we get this result over here which is true okay so text true equals true because we're switching it from boolean down here okay and we're running it through text we're converting it to text and now we have these quotations on both sides here so we know that is now switched from boolean over to text now in the inverse we can also take this example here which is essentially finding that same exact result which is down here is active and we're keeping it as boolean and now we have text is true now these might look literally the exact same but they're not they're totally different data types one is text with the quotations and the other is boolean not only are they a different color but the the main thing here is you can see these quotation marks on one side versus it being green in the other and so these don't play nicely with each other so if I take for example this filter here okay and I'm essentially saying that this JSON text equals true right here must equal boolean true so text true equals boolean true for it to pass and we run this and we're essentially judging it based on is equal to which is a text operator here we run this it will draw an error and the reason it's drawing an error is because we're trying to compare boolean versus text even though it looks very deceiving here we go into the JSON data we have text is true and boolean true and these aren't the same thing so even if we went over and we did boolean and we said is true and we tested this again it's still not going to work because these are completely different data types so in order for this to pass both of them would have to be text or both of them would have to be boolean the only alternative here is that we can choose is um is equal to here so is equal to boolean true and we can convert the data types where where required and this is a convenient little uh function that an has in it and if we test it now it's going to work because in this instance with this conversion it's converting these both into either text or boolean and so now it's matching properly so but that's really important to keep in mind that if you're comparing two different data types even if the value might appear as the exact same it's not and it's not going to pass a filter let's continue on with our example here we're going to go back here and we can see for the next example a math string here okay this is string you'd expect that 2 plus 2 equals 4 but in this instance 2 + 2 in strings equals 22 that is because essentially all we're doing here is we're adding 2 + 2 in string format this is very similar to if we said for example hello plus world and if we test this again now it's going to give us the value hello world we're combining text together and this is something that you'd expect if you were to to type in text like hello world it's just that we're unfamiliar seeing that as two numbers because we're so used to doing addition and having 2 + 2= 4 but that's not the case when we're dealing with text data and so this is the output here now if we were to take 2 + 2 as numbers then it's going to be four so just keep that in mind and this is kind of where data types don't play nicely and this is kind of confusing to a lot of people when they're starting out with JSON data the next example that I have here is the client um we have like this client array string so let's take for example client zero services what that is is it's here we have client zero is the index and um essentially everything has indexes the first item is starts at zero the second item starts at one the third item starts at three indexes always start at zero and so it's just the position in the array which is this square bracket here and so we're pulling out the services here and effectively in this if we convert this to string what that looks like is client array string we've taken something that looks like this with a square bracket and a square bracket and this is a list or an array and now we've converted that into uh text or a string and so if we look at the output here we know it's string because we have the quotation and the quotation and then the array within it and this is a totally different data type than this over here which has the actual array square bracket and square bracket right and I I think you're at this point probably kind of getting the the the point here in which these are not the same data types we are just going to go over a few more examples here which is going to be indexes okay we kind of already went over what an index is but more or less an index is the placement in a particular list so if we take a look at services here we have services one is marketing that two is SEO and ads is three but you'll notice it says 0 one and two and that's because in JSON or in JavaScript lists always begin with zero they don't begin with one they begin with zero and that is just something you're going to have to keep in mind so if we take a look at this particular text index here we look at this we say JSON.clients 1 we know clients is here and clients one is down here okay and then we have name.2 and we're looking at the name okay and we're getting the second index so if we look at the index here J is at index zero then A is at index one n as it is at index two and so if we're taking a look at the example or the result here I think my face is blocking it off but we can see it right here the result is n because n is at index 2 of this name if we were to change this to index let's say 8 and we run it again then it's going to be t so if we count this up 1 2 or 0 1 2 3 4 5 6 7 8 t is the eighth um character in the name and we get the result T here very similarly we have the index in arrays and so if we take a look at the client number one so we have clients client number one which is Jane Smith and then we go to the services down here and we pull out the second index we have index 0 1 and two so we're pulling out branding here and we can see the result here which is branding because we're pulling out the second index which is technically the third item in the list but because arrays start at zero we're pulling out branding which is at the index of two moving past this we have just a couple more things that I want to mention here before we wrap up um these kind of data types switches functions and all that kind of stuff and we're going to talk about functions here lastly and so I want to talk about two particular functions we have a join function and then we have a split function now in a nutshell we have using nadn the ability to switch between data types here right so if we pull this down we have multiple different ways of switching data but we can also do this through functions too and a function is essentially just a you're executing some code right and JavaScript has a ton of built-in functions so if I go to JavaScript built-in functions here oops JavaScript builtin functions and I go to the first results here there is just tons and tons and tons of different functions here and all of these functions do different things more or less and uh yeah you can come in here you can read some of them some are going to be useless and I've never used in my entire life and some are actually super important and so bottom line is is that there's lots of different things and we can execute these functions using JavaScript and in NAD if I was to open this up and I was to hit curly brace curly brace everything inside here these curly braces is now JavaScript so now these functions will work and we can use JavaScript functions the cool thing about JavaScript functions is you don't necessarily need to be a programmer to use them because they're like boilerplate things so once you know them you know them so take join for example here essentially and this is kind of like not a good way of showcasing it so I'm going to open this up essentially we have this join function and what we're doing is we're taking a list here so we have clients one and services and we're taking all of these services and then we're going to turn it into text join turns and a list or an array which is here we can see the array item or icon we're turning that into text and we're spacing them out by comma and then space so now we're taking content writing social media and branding and now it's coming back in the form of text with a comma and a space in between so that's pretty cool right so that's another way of essentially changing data types using a function and we can see the results again down here okay and so that's pretty important now if I was to zoom in here we can also see that we have the quotation mark here and we have the quotation mark here so technically this is turning a list into text because we started with a list here and then it became text and lastly we can also turn text into an array or a list using the split function here so let's take for example the first client or the client at index number one their name so if we look at client number one their name Jane Smith and we split we run the split function on her name we we're putting in a space here and what this is doing is we're saying hey we want you to find this character which is a space and the space is between Jane and Smith and anytime you see that space I want you to essentially break the text and put it into a array and we can see the value here so if I open this up now we have an array or a list separated separating the values by space and because we started with Jane and Smith and there's a space in between now we're getting an array or a list of two items two text items first is Jane second is Smith if I was to go in here and I was to change Jane Smith and I put in another one like Robert Jane Smith Robert then there would be a list of three things jane and then Smith and then Robert right and more or less in a nutshell if I was to zoom in and I'm not sure if you're able to see this but if I was to zoom in this is the results down here we have an array bracket here an array bracket here of two text items Jane and Smith and so that's essentially how we can use functions inside NAN to get uh to change the data types and lastly we're going to move over to um lists here and we're going to go to this second scenario here so let's go ahead and get this started in this scenario what we're doing here is we're essentially more or less talking about iterators and aggregators this is an iterator here this is an aggregator here and we're dealing with lists so if we circle back to our particular um grocery list here let's say that this is you down here you make your way over to the grocery store okay and when you get there you walk into this store the first thing you're going to do when you get in here is you're going to go to the grocery aisle or you're going to go to the produce aisle and you're going to try and find the things on your list and think about like logically what happens like if we just break it down to the the very core of things you're going to probably start at the top of your list okay with apples and you're going to get apples and you're going to cross off your list you're not going to get oranges you're not even going to start getting oranges until apples is gone right so you're going to start at the top work your way down chronologically one by one you start with apples only after apples you get oranges we're not at mangoes or bananas yet because we haven't locked in oranges and so you're going to cross this off and then once this is done then you're going to move over to mangoes and then you're going to cross that off and then you're going to go through to bananas and you're going to cross that off and the reason I'm explaining it this way because it seems probably pretty simple like intuitive right is this is exactly how arrays work you you can you can have a list okay and you can go through these lists one by one by one by one one at a time and if we circle back to NAN here we can run this workflow and view the same thing happening here so if we look at this this um second workflow we have data here let's take a look at this data we have multiple different clients here we have John Doe John Doe Jane Smith Robert Johnson first things first is that we have a duplicate which is John Doe and John Doe this is on purpose then we have Jane Doe and then we have Robert Johnson and if we look at the status here they're all true except for Jane Smith so what happens if we get a list of data like this and maybe we don't want duplicates in here we want to remove duplicates or maybe we want to remove people with a status of false well if we have a list here this is just um one type of data it's it's a it's a list um but we need to go through similarly to a grocery shopping list one item at a time and we want to remove the duplicate one item at a time and we want to remove the status equals false but we can't do it on one array we have to do it on an item by item or object by object basis and so this is where the split out comes into play so if we look at this we have one item okay that item again is all of these clients here john John Jane Robert but all of them are within a list and that list is one item then we run the split out here and you will notice right away that it converts that one list into four items okay and these are our four people John John Jane and Robert and then we have a filter here and this filter is going to remove anyone who has a status of false and then we're left with three people because Jane was removed from the equation so if we come back in here we can see that Jane was false and if we look at the filter here we're essentially saying that the status has to be equal to true and we kept three and we discarded one and the person we discarded was Jane because she was false and so circling back to our example here we started with a list then we got all four people out then we filtered out Jane okay and then we removed duplicates and because we had two John's in here John and John we removed one of them and then we are just left with two people after that and then we added both of these people to a Google sheet so let's take a look and we can see I just added this person in as like an example here and then it ran again it ran again and we have John and Robert added in and they're both approved phone number email everything added in here okay and so we added both people in and then what we had here is these two people left over and then you can add in something like a limiter for example and what a limiter does okay and by the way if we go and open this up and we go into data transformation the limiter is right here what this does is we say hey we only want to take like one person or two people or three people or whatever and you can choose from the beginning or the end of the array and so I could choose here from the beginning which is John or the end which is Robert and in this case I just started from the beginning and I said only one person can pass if I did two people here and tested this again it would keep both of them but because I only want one it's only going to take the one and this is how limiters work um inside nad and so then it's left with one and then it bundles them back in together now I'm just going to actually keep this as two okay and we're going to run the scenario one more time and now we'll notice that we have two when we hit the limiter we keep two and we have two and this is important we have the array aggregator and now we go back to one right so we started with one and then we ended with one and the thing is is essentially the split out and the array aggregator are the exact inverse the split out brings an array and goes through them one by one the array aggregator takes those individual results and then bundles them back into an array so if we were to go back to our grocery list here with the iterator or the split out function so we have iterator or split out we're going through these one by one by one by one and once we're going through them one by one by one the aggregator bundles them all back into that list again and we're saying okay 1 2 3 or four or whatever however many there are left and so if we take a look at the results now of the aggregator we can see that we have um the data here and this data contains an array well it is an array of two items and we're merging everyone back in initially we started this um or we were going through them one by one and then we added them back into a list and why this could be important by the way is because let's say for example you want to email yourself with all the leads that you get in a day and let's say you get a,000 leads a day you probably wouldn't want to split these leads out and then send yourself a,000 individual emails your phone would be going off like crazy it would be like insane i'd feel bad for you imagine being at like a dinner party and you're like you know trying to explain yourself and then your buzzer goes off like a million times it would be awful um but with this array aggregator we can merge all of those 10,000 leads into one particular um email so we could send out all those thousand leads just in one email instead of a thousand individual emails and so that in essence is how iterators or split out functions and aggregators and arrays work in nan so that's more or less it in a nutshell thank you guys so much for watching if you made it all the way through really appreciate your time if you have any questions leave them down below in the comment section if you found this valuable and you haven't subscribed to my channel yet please go ahead and do so if you if you like content like this because if you do I'm going to be releasing future content just like this and I'm sure you're going to love that as well and lastly if you guys haven't taken a look yet I do have my school community over here we have 294 members we launched about a month ago and this is a place to get additional help so if you're looking for um more courses more templates and blueprints if you want to jump on calls weekly calls uh weekly Google calls this is the place to do it and we can debug and troubleshoot any issues that you're currently going through bypassing tons of time trying to figure out the hard way how to uh overcome issues so again guys thank you very much for watching i hope you have a lovely day and I look forward to seeing you in the next video thanks and bye-bye