Understanding JSON and using GSON in Android with Kotlin and Android Studio

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up youtube this is dennis paneuta for tutorials.eu in this video you are going to learn about json and json and json is basically something that you will need all the time and json is something that you will need specifically for android development so this is going to really help you out to understand what json objects are how to read json how to use json in your android project and then even up that and increase your productivity and your efficiency by using a third-party library called json so json and json and by the way you might notice that the sound quality is slightly differently even though i'm using the same microphone and that is because i have finally figured out that i have an rtx graphics card and i can use something called rtx voice which basically uses ai or machine learning in order to get rid of all of the noise in the audio so there might be a shift in sound quality from what you can hear now to what you hear in the actual recording of the content of this video but for future videos i'm definitely going to use rdx voice which is freaking awesome so if you have an rtx definitely check that out for your meetings that you have using your microphone it will do wonders to your audio quality and then there's one more thing please hit that like button and the subscribe button that really helps out this video and the youtube algorithm this is another 40 plus minute video where i'm going to teach you everything that you need to know about json json and all of the good stuff for your android projects and also leave a comment if you like the video or if you have any questions any feedback on what should come and a little bit of an update on what i'm going to work on throughout the next weeks and that is a new course so i'm working actually in multiple courses in parallel might not be the most efficient way but that's just how it works for me working with some of my employees and working on good content and basically we are working on a shop app so we're going to build a shop app i did a survey and the ones that have my android master class they could answer that survey and they could basically influence the next course which will be the shopping app and in that shopping app we're going to use firebase and firestore and it's going to be amazing so there will be a little teaser video coming up in the next weeks and also some other content from that course you will also get roughly a quarter or a third of the course here on youtube so be prepared as well as a bunch of very useful demos that will definitely help you to become a better android developer so hit that subscribe button right now if you want to not miss out on any of those great videos and also hit that notification bell because it's going to be amazing all right so now enjoy this video thank you very much for being with me let's get started all right so let's get started with jason and i don't mean jason stethem as one might expect based on the name but i'm talking about json which is written like this and we are going to start with j sun and then we're going to look at g sun which is very similar to json but it's a g instead of a j and that's a third party library that we're going to use to make our life even easier so first we're going to start with what jason is and how to use json and if you want to read along and want to basically get the code as well not having to type everything in manually you can get it on my website tutorials.u and then well you can actually also find the link in the description down below all right so let's get started with what json stands for json stands for javascript object notation and it is basically used in order to exchange data and usually you would find json data for all kinds of data that you would find on the internet to display it in a certain manner for your website or your application whatever so you get the data and then it's your task to do whatever you want with the data for example if you want to get weather data or if you want to get the latest results of sports events or whatever one could think of putting online in a workable format in an easy to use and consume format for an application they would use json even though the xml format is an alternative format but that's something that is quite old-fashioned i'd say basically nowadays you would really prefer to use json and that's also what you would usually also get in terms of the type of structure of the data that you get let's look at the json object so here this is an example of a json api response that you would get so basically what we are doing is we are most of the times requesting the data via an api so we get an api response we send it for example to openweathermap.org and this could be the structure in which we get the data so this is the json format and you can see you get a bunch of information for example the city the cod the message the list of details of the weather for example the temperature during the day the minimum the maximum night and so forth so you get a bunch of data even though you might be confused about the values that you get here and that is going to be probably kelvinites i guess so if it's 293 that should be something around 22 degrees celsius and yeah basically this is the structure in which you would get json data so if you have a list then you would use square brackets if you just have objects that are structured inside of it then you are using curly brackets and basically json object always starts with curly brackets so we have json objects inside of this json object which is for example the city which contains a json object that has a bunch of info the id the name the coordinates and the coordinates itself is also a json object that you would get for example the longitude and latitude and this is the city then you have cod which is basically just simple information just a string you can see you can get the information in a float format and an integer format and you can even get a whole list off then again json object so this is another json object here and it could be even longer so you can see that with those dot dots here quick pause so you're learning something about android in this video and i hope you enjoy it if you want to learn everything that you need to know to become a real android developer then definitely check out my android master class because in this course you're going to build a bunch of great applications along your journey to becoming an android developer first you're going to learn the kotlin basics then you're going to learn to build one app after another and while you do that you get a bunch of demos which will really dig deep into the concepts as well as presentations which will help you to understand what you're learning so don't miss out and get the course right now you can find the link in the description below and basically if you have a list it starts with a square bracket then you can have a bunch of json objects in there and it ends with a square bracket even though they don't have it in this particular example but for this weather here for example you would have the weather which can be a list of multiple objects and it starts with just one or it contains only one and it says the weather is only id 800 the main information is clear and the description is the sky is clear so a little more text about it and then you have a specific icon where they say it's the icon01d so if you would want to use their icons you could even use the icon for for example for clear weather okay so this is just an introduction to what json objects can look like this is really just one example we have a very different example for our own data so if you want to look at that you will see that we have a list of users okay and we have a bunch of information about the different users so we get the data from let's say an api that we're using and we want to display that data in our application for example if you use a tool such as facebook well they also store their data or they make their data available in json format and you would always just get a part of the information of course so we need to understand json once we want to make more complex applications that communicate with the internet okay and that is the situation rather quickly when you are an android app developer at one point you realize okay i need to understand json i need to understand apis i need to know how i can get this data from the web and then use it in my application and in this video we are not going to focus on how to get the data from the web this is something that we do in my complete android master class for example and if you leave a comment in the description and say definitely create a video on that well if that comment is going to be liked quite a lot then there is a chance that we are going to create such content as well but basically what we are going to focus on is really json itself so how to get this format into basically then displaying it in this format here okay where we have the different information and we displayed them in an easier to consume manner because what we had there was json a format that is still rather easy to consume i'd say but still is not something that you would like to display in an android app directly so what do we have here so this whole thing here starts with a curly bracket so it goes all the way down here this is a json object this whole thing and it contains this user's list which is a list of json objects and it starts with the square bracket and it ends with a square bracket here at the bottom inside of it we have a bunch of objects which is a list of objects right so this is the first element of this list of objects and it has an id a name property an email a gender weight height phone number which itself also has more details so this phone has a mobile as well as an office detail so a property for mobile and a property for office and i'm talking about properties here because this is something that you can really re use in an object kind of format and that's something that is allowed by basically converting it into a json object okay this here because there are a bunch of classes that android provides and is the json object one json array json stringer and json tokenizer i think at this point i have talked quite a bit about the json objects and the json arrays are basically the list that i was talking about so if you use the json array class well that's what it is then the json key value that's for example the user name and then whatever comes afterwards is the value so the json key value pair is basically this is the key so here username is the key and then this panetta would be the value and then we have a bunch of parsing functions so functions that allow us to get information about this particular object or json array that we're looking at so we can get the index of that object we get the type the length meaning how many entries do we have in this array this can be very relevant because you potentially want to loop through them to get all of the data then opt which returns the object type and the opt type which returns the value of the mentioned object types a json array on a particular index so now let's actually use all of that because i'm 10 minutes into this video and i haven't even started building a project with you yet let's do that now and by the way it was important for you to understand these kind of things that i was talking about for you to get a better feeling for what we are actually going to do because we are going to now look at how we can use all of those json objects in an android environment first of all using the classical json parsing methods and then using a third-party library which is going to make our life significantly easier because it offers you a bunch of options that basically reduce the code that you have you have less boilerplate code and that means that you can basically get quicker results with less work all right at this point let's create an empty object project and i'm going to call this one json example and we're going to use kotlin as the language as well as the minimum sdk being android 5 because then it runs on most devices which is what we want because we're not using any latest and greatest technology here we are really just using the basic functionality that android offers all right the next thing that i want to have is a folder where i can put my assets okay so i'm going to go ahead and create a new so here at the top level at the app level i'm going to create a new folder and you can find it here folder and i'm going to call this one we're going to select the asset folder here and well let's basically just click finish that's going to be fine now we have assets so this is the new folder inside of this assets folder i want to create a new file so right click new and i'm just going to create a file here i'm going to call this one users.json okay so here i'm going to copy in let's see what we got here right so make sure to copy this whole code here and paste it into the project here because this will be our users data and this is something that you could also get from the web and it would contain significantly more data but we just have three users here actually it's four users and we kept it very simple we have a little bit of information about those users and that's basically it and by the way i'm not 182 i'm rather small and 169 and i'm also less heavy okay so this is the users.json file and now i want to use this in order to display its data in my ui now let's go ahead to our build gradle so our build.gradle file and here i want to add an implementation and down here so basically you can see all of those different implementations that we have all right then at this point add this implementation here saying [Music] com.google.android.material.commaterialcolon1.2.0 and make sure that you sync it so if you make changes here in your gradle file you have to sync now once you edit this line click on sync now and then it will take a little while your cradle will do its magic and then you should go to your activity main because that's where i want to add a recycle view so here i have added this recyclerview and basically i just pasted it in you can copy this code from the my website as i stated earlier and if you have no clue what a recyclerview is i would highly recommend that you first check out what a recycler view is before you move on because we are going to use adapters and all of the kind of stuff that is connected to recyclerviews basically it's just a list right but you definitely need to understand that and i created a video that teaches you recyclerviews in depth and really makes everything clear okay so once you have the recyclerview you also need to define how your item should look like okay so i'm just going to create a new file in my layouts a new xml file and here new layout file which i'm going to call item underscore user underscore layout so this is going to be my individual layout and you can even keep the root element as constraint layout everything is fine i'm just going to override it anyways and basically what i have in here is how i want one individual item to look like okay you can see it here we have the id the name email gender weight height mobile number and office number and you guessed it this is the information that you can find in every single user okay so this is the json object that contains all of the details for one particular user then this is the second object and with the third object and so forth okay so this is what this item user layout should all take care of and that's the code for it and again check out the code on the website because this video is really not focusing on how to create a ui i really want to focus on json okay now the next thing is a little more interesting and a little more relevant to this particular json example so because we are going to require a data model okay so i need to have a new folder or i can create a new folder you could of course also just create a new class but i'm just going to create a new folder in here which is going to be a new package and i'm just going to call this one model okay and in this i want to have my new kotlin file class and it will be a kotlin class which i'm going to call user model class because it is going to be the model class for a particular user so basically it should contain all of the relevant properties that my user has and what are those properties let's look at it it's the id it's the name email gender weight hide phone mobile office and what really helps is if your class has those in the right format and the right naming as well so let's look at it so i need to have the value id which will be of type integer the name which is of type string email which is of type string gender is also a string the weight if we look at it is a double value or it could be a float but i'm just going to use double here the height will be an integer so here height is int mobile is a string as well as the office is also a string as you can see here so it's not numbers you could of course store a mobile and an office number as a long value but i think it makes more sense to use them as strings and it really depends on what the data is going to be like if you get the data in a long format well then you of course have to use the long data type here okay but as it is a string i'm going to use string so now i'm getting this error here and you might be confused about where this error comes from because what's the problem with this class well because it is going to be a model class a data model class which is super basic we don't need curly brackets here but just rounded brackets okay so just basic brackets here and then the error disappears and this is basically how a model class will look like and these are going to be all of the different values that we are going to get from such a json file okay now at this point we need to have an adapter and we are going to use an adapter class that i'm going to create here so new kotlin file class this will be a new class and i'm going to call this one user adapter and i'm going to need that one for my recyclerview okay so if you were wondering what this whole recyclerview is and all of that as i said check out the video on recyclerviews all right and for all of those arrows to disappear i also needed a bunch of imports so you definitely need to import context then the layout inflator view view group recycler view and so forth for all of this to work you see i'm using the user model class as my model for an individual item and my user adapter that's why i needed to import that but again i'm going to skip that user adapter here because basically i'm just assigning whatever item i'm getting to my holder which basically holds the tv item which is if you look at it that's our user adapter which then basically holds view dot tv id which is if we look at it this design so what those three things do and i explained that on a very high level here because just to refresh your memory if you have watched the recyclerview video a while back basically we always have this connection between a recycler view an adapter and the actual view so this is the actual view which contains all of those different view elements and i want to assign the id that i get from my model from my user model class i want to assign it to this particular view element what is this view element well it's this text view which has this id called tv id and if we look at our user adapter inside the view holder we can see that we're using view dot tv id which basically just means for that particular item that we're looking at i want to assign the text view id and i want to assign it to the value tv id to this variable basically that we're creating and this by itself is then bound with the bind view holder or unbind viewholder so once this method is called it will bind whatever item.id is to our holder.tv id text which will then basically allow this here to display the right id the right name the right email and so forth for each and every one of our users so for user one for user two for user 3 and so forth okay and now let's see how all of that is coming together and we're going to do that in our main activity class so let's look at it we're going to need a couple of imports here as well so let's import user model let's import it json object and json exception and all of the good stuff so i will need to import my different classes so that i can use them without getting a bunch of errors here okay so once we have all of them imported and by the way you can again get the code in the link in the description just check out the website so basically what we need here is a list of our user model class so this user model class is basically our model class for each and every single object that we have for each and every single json object that we have okay so this one here and then in the next step we create a list here so in this case it's an array list of objects that are of type user model class so it's not of type string or int or something basic but it's really of the type that we have defined ourselves which is a lot more complex because it has all of those different properties which are these ones so properties to be a little more precise with the pronunciation so at this point we have an object which is of type json object so we say okay we want to have an object and when then we define it should be of type json object and this json object it requires a string json and can throw a json exception and that is why we need to add this trine catch block okay because it can catch this exception that was thrown okay so then what we do here is we get the json from assets and this is an optional that's why we need to use the double exclamation mark here and then we get the user's array from that object that we just created and we get its json array called users okay so if we look at our users.json you can see that this here is called users and it is a json array because it starts with a square bracket so this here basically is a json array all the way down here this is one json array which itself contains json objects okay and that's what we are getting here so we are saying give me the users which is of type json array and store that in this variable called users array so now with this for loop i'm reading all of the data for every single entry inside of my user's array so for i in 0 until uses array.length so what that means is i say go through every single object inside of your array or inside of this array start with the first one and go to the last one so user's array that length will be four so go from the first to the last one and then from every single user that you have in there first of all create a user out of the complete object that you have that will be and json object again so if we look at it this here this part is a json object okay so this whole thing is a json array but it contains a bunch of json objects and every json object can have a bunch of key value pairs okay so this has the key of id and the value of one the key of name and the value of then is panetta but it can also have or a value can also be a json object itself so this for example is a json object and this is a key called phone but the value of phone is a json object itself which has again a key of mobile and a value of a string and that is something that we are going to take into consideration as well here so first of all we get the id and how do we get it well we get from it from this user which is we the user's array that json object at the position i so basically in the first iteration it will be this one in the second iteration it will be that one and the third iteration it will be that one and so forth okay so we get all of them and for each of them what we do is we get the json object and then we treat the json object in our kotlin manner where we just say okay user dot get integer at the key id so we get the id then we get the name the email the gender the weight the height then the thing is as you can see the phone and the mobile and office they are a little more complicated because while mobile and office are very easy we also use getstring here the phone number itself even though we won't display phone what we will display however is mobile and office but they are those are json objects themselves or this is also a json object as i explained right so this part here starting from here as it is in curly brackets this is a json object again so i need to make sure that i'm breaking it down and getting the phone object which then contains the key value pairs which basically means it contains the mobile with the value for mobile as well as the office with the value for office and now that we have all of those values right we have all of those basically strings and integers and doubles so here an integer this is an int this is string string string double and string string we get those and we can make an object of our user model class so we create an object with all of this information that we just got and we create an object out of it called user details which we then can add to our users list because our users list if you recall is this arraylist which is of type or which contains elements of type user model class so which is basically this model class here so all of that work was really just there for us to so this whole work here for us to add every single object that we have here to our list which is this arraylist here because once we are done with all of that we have our list which we then can assign to a recyclerview okay a recyclerview is a list view so to speak so basically a way to display a list in android and we're saying we want to use this recyclerview user list which is going to use a linear layout manager and then this adapter as you might recall it needs a context as well as a list so let's look at user adapter once again it needs let's go up here it needs a context and it needs a list of an arraylist of user model classes now guess what our user list here is of exactly that type that's why we use this type of course so now we have basically this list we can give it to this item adapter and we can give this item adapter to the recycleview's adapter and this is basically always the same structure but that allows us to then display the json object data directly inside of our recyclerview which is basically a list now there was this method here get json from assets and you might have wondered what the heck is that because i don't really know where this comes from well the thing is i have this extra helper method that i created which is just for that so it gets us to json from assets and it will return a string so it will return json what is json well it's a string nullable that's why we have this question mark here basically it's a variable that can be null or can have a value that's what the nullable is and then we have a char set where we use the utf-8 charset so if you want to know more about char sets definitely check out char sets on the internet i mean i'm not going to go into jar sets here but basically there are different types of character sets and we are using the utf-8 which contains a bunch of characters that we are using except for example the ones that you can see on your keyboard okay and then we try something here as well where we say the value is assets open users.json so here this uses.json is the file that we have created in our assets folder so that's why we use assets.open because well it's in the assets folder and we open a file with the name users.json all right now at this point you might wonder what is this is and basically this happens when you convert from java code to kotlin code this can happen so let's say i had this variable which was called is in java and now i'm converting it automatically and that's the cool thing this ide allows it so um well android studio allows the conversion of java code to kotlin code then this thing can happen and java is is not a specific keyword okay so you can call your variables is but here you see that this is a keyword that is used in kotlin and this is just a little side note that you can still use variables this way even though i wouldn't recommend doing it so it's better if you give this a more meaningful name like my user.json file or something like that that would be probably a more meaningful way on users json file that would be a more meaningful variable name and then you come or don't come across this arrow okay this was just a little side note for you all right so basically we have this json file now so we open our users.json which is this whole file basically this complete file and then we need to know the size of the file and we can get the size via the dot available function which you can apply on assets that you open then we need to pass that to our byte array well the size that we just prepared and basically this is going to be the buffer and then you can read your file with the read method but you need to pass the buffer and once a file is done reading you need to close that file reader as well okay so well you need to close the file so we're opening the file we're reading everything we are storing it in the buffer and then we're closing the file again and at this point what you can do is you can make a json object out of it or a string object out of whatever the buffer had and we are converting that into a charset so basically this is the code that you will need whenever you are reading a file which is of well in this case json format but which is just a text document so to speak and you need to read it well that's going to be the code that you are going to use for this again because this can go wrong we have this try block because every time you are reading a file that could be something wrong the file could be corrupt or there could be a wrong data type or whatever that's why we're using try and catch here and then we are returning this json file which is basically going to be of string nullable type and that's what this get json from assets is going to give us so now going up here you can see that we get a complete json object out of this whole file that we created up top and then we do all of the magic that we saw later on and at this point if you run your application you will see that this is basically what you'll get okay so you now have all of the items or all of the json objects in recyclerview and these are the recyclerview items that we are using here you can see we get the id the name the email address and so forth and all of this in this particular format that we have defined okay so yeah that's basically how you can get the data from a json file so let's say now we had more information here so let's say we have a fifth entry and this will be frank and his name email address is going to be frank at gmail he's male and he has a different weight whatever and he is a little taller super skinny guy and now if we rerun this and refresh the application you can see that frank is also there okay so this is how you can now get all of the data and you can see it's super adjustable so if you get more data from the web now and you refresh the application you will see that you will get all of the data that is available and in a specific format so now it's your job to make it more appealing and look make it look like you want it okay and that is the generic way the json default way so to speak using all of the json available classes made directly available by kotlin but there is an even better way to doing all of that and that is to use the json library so now let's look at how that would look with json okay so we still need this list here this users list but now we also need to make sure that we are adding another implementation to our build.gradle so let's go to our build.gradle to the app one and let's add this line here implementation com.google.cod.json colon json colon 2.8.6 once you edit that you need to sync it and now you will be able to use the json library and let's have a look at how to do that so the thing that will change now is that our data class that we had before is going to look a little different so we had this data well this user model class right and this user model class contained the whole object basically in one class even though if you look at it our json objects that we have here are multiple ones so this is the highest level this is going to be the users class which will itself contain this class type here which is the user model class you could say even though inside of that we have the phone data class which is basically containing these two properties so how can we convert this class that we have here into this format because we are not using a data class we're using a generic class but we could use a data class and that's also what we need to do when we want to use json okay so i'm going to create a data class here which is just a more efficient and simple way of a class which is really just there for data structures so to speak so i'm just going to say that i want to have users which will be of type arraylist which will be of type user model class okay so now i want to have a bunch of users which are of type user model class and now inside of this user model class i have another data class that i will need and by the way let's make this also data class and here this will be the phone data class and now what are the properties that i want to have inside of this phone data class well it is those two here so let's cut them out from there and here we are going to require a phone which will be of type phone okay so basically i broke it now down to a format which is perfect for json and which is also a lot more clean so to speak because if we look at our data this itself is an object right so phone is a json object this here is a json object this whole thing this complete part here is a json object which contains a list of a bunch of json objects okay and that's why it really makes sense to break it down in a cleaner fashion which is what we just did by using data classes here and basically we say that our user data class basically isn't contains an arraylist of user model classes or model class objects and in there we have a phone which is or basically we have all of those different properties right but one of them is phone which is by itself of our data class type phone that we created which contains this information here okay this will be a lot more performant and is also a lot cleaner when it comes to more complex structures in json objects because this is a rather simple structure you can get data in a significantly more complex manner but using json and step or preparing everything in a way that you can see here is going to be the best way to go okay and let's see how we have to adjust our main activity because you can already see that we get an error here because mobile and office are not strings anymore so we don't have phone dot get string mobile so these two lines they won't work anymore all right so now let's make the changes that are required for using it in json okay and basically it's really a lot that we are saving here inside of this for loop here or inside of our try and catch block we can basically get rid of using everything inside of here like this complete for loop actually even all the way up here so let's get rid of that and all the way down here so we don't need all of this part so where we did the for loop and all of that because json allows us to make it a lot a lot shorter so what we need is we of course need to get the data and we do that by using json here so first of all we get the json string now from our assets directly and then we get the users from our users class and well thing is did i call it users let's look at the data class that we have here i call the user let's call it users actually so this data class now is going to be our entry point so to speak and now i need to import users as well and then i need to make sure that my layout adapter here at the bottom is actually using this users and so forth okay so let me actually cut it out here and put it into the try block as well and here now we need to make one little change because we're not using the user's list anymore but actually we're using users directly okay so we're using this users here and what do we use from users well dot users this is a little confusing but if we look at it it's this property here called users inside of users okay so now we're using this users here and you can see we can even get rid of this users list that we had before so basically what we had before was we had to create this users list then we had the json object that we had to create we had to create the user's array from it then we had to loop through the whole array we needed to add every single element to the array list and then at that point we could then start and adding everything to our adapter and everything right and displaying this kind of code but now we have all of that in just five lines of code because well i have comments in here but basically it would just be five lines of code because json is smart enough to basically get all of the data by itself so what we just needed to do is we just needed to get the whole object which is this complete object and have the right structure so basically in our user model class use the right structure which we did and then jason does all of the action for us and well saves us a lot of time okay because at this point we can rerun our application and see if the code will still work and well i that's perfect so i still get these two errors because now in our onbindviewholder things have changed because now we don't have item.mobile directly anymore but we have item dot phone dot mobile now and the same goes for office so item.phone.mobile as well as item.phone.office because we have this new structure right we have this structure where our phone is a data class itself which then contains the two properties that we are going to require which is mobile and office so at this point we should be able to rerun our application so it's going to reinstall it and let's see if we still get the list and you can see we still get our list as we did before so now you see that using json which is a google library is significantly more efficient and is also going to be used in third party libraries such as retrofit and many other third party libraries because they just say well well why shouldn't we use this beautiful third-party library called json if it saves us so much time and hassle and also gives us the data in the perfect format that is clean and that is just build up on each other so once again real quick these three are basically what we have in users so let me put it together so this one here is our complete users object okay this data class here then if we open it this part let me close this phone as well this part here is an individual so each of those ids is an individual user model class and the user model class consists of all of those properties that we had plus the phone which is another data class which we then also created so now let me adjust this real quick just a little bit so let's say i would go even one level further and about the phone i would also store even more information such as let's say i would have details about it and this would itself be of another data type here okay so basically it would have information about let's say the brand so let's say it was samsung and then the model let's say it was fold two okay and here i'm missing the colon so let's say we had this structure how would you now change your whole structure up so what would you change now just a little challenge for you try to pause the video and try to figure it out okay so for this to work now and let me actually do that for the user model directly we would need to go ahead and say val and here's comma missing val details and i would create a new data class here called details and it would contain information about the brand which is a string and the model which is also a string okay so this would be then of type details and now at least our class here or this model class or this model file so to speak follows the same structure as i had here with my json file now of course it wouldn't appear anywhere we wouldn't display it anywhere because if we look at it our user adapter has no clue what this details is about as well as our xml file doesn't know about details so we don't have details in here so we would have to adjust those as well but that's not what i wanted to talk about or focus on i really just wanted to focus on the structure that you would have to take care of with your data class as well as your json file and so forth okay so if you want to you can of course now try to then implement the j the details as well to add basically the xml entry so add another text view just underneath it for example with the additional information and so forth okay i'd say that's pretty much it for json and json and all of the good stuff so i hope this helped you out i hope you have a better understanding of how to use json objects now what json objects are and how you can use them in android directly using kotlin but at the same time also using the third party library called json which does a lot of this action for you and saves you a lot of time and headaches later on because this really makes your whole development process significantly easier as well as more secure because things just don't go wrong this quickly if you use this json instead of json all right so that's it for this video i hope you enjoyed it i hope you now understand what json is and json is on how to use those to now being able to use online data or data that you get from apis of course as well as json objects that you get in other formats alright so now what you need to do is to check out one of those videos and of course not forget to hit that like button alright i hope to see you in the next video have a nice day
Info
Channel: tutorialsEU
Views: 9,022
Rating: undefined out of 5
Keywords: JSON in Android, JSON in Android Studio Tutorial, Using JSON in Android Studio, using gson in android studio, parsing json using gson, GSON tutorial kotlin, GSON tutorial Android, how to use gson in android studio, Basics of JSON, how to parse json in android studio, how to parse json using gson in android, how to parse json using gson, Parsing basics in android studio, json tutorial for beginners, json fundamentals in kotlin
Id: zdfbHzBmzk8
Channel Id: undefined
Length: 52min 2sec (3122 seconds)
Published: Fri Sep 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.