Placeholder Image

字幕表 動画を再生する

  • Hello, everyone.

  • My name is Kyle and this is webbed of simplified.

  • We make the Web easy to understand and accessible for everyone.

  • In this video.

  • I'm gonna be going over Jason, which is one of the most important concepts that you can learn as a programmer or as a Web developer.

  • I'm gonna be going over what Jason is.

  • Why you should know it.

  • And all this in tax involved with Jason and the end of the video.

  • I'm going to go through examples of Jason, so make sure you stick around till the end.

  • Jason, also known as JavaScript object notation, is simply a data representation format very similar to XML or yeah, no, it's used widely across the Internet for almost every single A p I that you will access, as well as Burke and FIG files and things such as games in text editors like GS Code and many, many other places throughout programming.

  • It's used because it's extremely lightweight to send back and forth due to its small file size.

  • It's easy to read compared to something like except metal, since it's much cleaner and there's not as many opening and closing tags to worry about, and it also integrates very nicely with Java spirit.

  • Since Jason is just a super set of Java script, which means anything you write.

  • J.

  • Jason is valid.

  • JavaScript.

  • So ingrates Nice to the job disappeared, which is used all throughout the Web for front and or back on level of applications.

  • Also, almost every single major language has some form of library or built and functionality to parse Jason strings into objects or classes in that language, which makes working with Jason data extremely easy inside of a programming language.

  • Throughout your programming career, you're going to use Jace on all the time.

  • Whether it's created an AP I consuming an A p I or creating config files for you, you'd or for other people to use for your application.

  • Now that we understand what Jason is and why it's important.

  • Let's dive into some of the syntax involved with Jason by starting by talking about the types that Jason could represent.

  • As we know, Jason is a data representation format, so we need to build to represent a certain data types within it and Jason Natively support strings numbers, and these numbers could be in any format whether they're decimal numbers, whole numbers, negative numbers, even scientific notation numbers.

  • It supports billions, which could be either true or false supports.

  • Know which essentially stands for nothing a raised, which could be a list of any of the types that we've talked about.

  • Plus the next type, which is the final type of object.

  • An object is the most complex but most used type within Jason, and it allows you to represent values that are key value pairs.

  • So you give it a key and then a value, and that value could be anything of the other ties we've talked about.

  • So straying number bully, an array know any of those different types can be the value for a key.

  • So let's dive into an example of how to use Jason inside of a file.

  • The first thing that you need to do is to create a file with the dot Jason extension.

  • At the end of it, that's dot J S.

  • O N.

  • At the end of your file.

  • Metal, create a Jace on file inside of this Jason file.

  • What you do is you take one of the types that we talked about and you put that inside of the file.

  • So, for example, you could put a string.

  • You put a number of bullion whatever time you want inside of that file, and that's valid, Jason.

  • But if all you have is a single string or single number, it's really not very useful to have a whole file for that single input.

  • So what?

  • Most of the time, when you're working with Jason, you'll have either an array or an object as your top level of your file.

  • And then inside of that array or object, you'll have other values.

  • So it may even have other objects have other raised or even just individual values.

  • Just strings are numbers inside of that.

  • So it's taken example of a user object that we want to put at the top level of our Jace on file, which we're going to call user dot Jason to create an object we need to use opening and closing curly braces.

  • And then inside of that will put all of the key value Paris that make up our object and every single one of these key value pairs.

  • The key must be surrounded by double quote, followed by a colon and then the value for that key.

  • And then if we have multiple key value pairs, we need commas separating every single one of our key value pairs similarly, to how we would create an array in a normal programming language.

  • So, for example, if our user has a name which surround that name, key and double quotes, put a semi colon after.

  • And then we'll put the value of our name inside of double Coach as well, because the string and it must be in double quote.

  • And at the end of that we'll put a comma because we have other key value pairs for user.

  • For example, if we wanted to use a favorite number as another property, we'll put favorite number in double quotes, followed by a semicolon, and then put that users favorite number.

  • Then, if we wanted to use a Boolean, we use a comma and then another property.

  • We would use his programmer as Archy, put a colon, and then we had put either true or false with no quotes around it, to signify that this is a Boolean and not a string.

  • So we would put true or false, depending on if that user was a programmer or not.

  • We could then go down and use hobbies as our next devalue pair.

  • So put hobbies and double quotes, semi colon.

  • And then to creating that ray we use opening and closing square brackets and inside of the array, we put whatever type of value we want.

  • And in this case, we're just going to your strings for the different hobbies.

  • So we'll put those strings inside a double quote open Commons between each one of them because we put commas between all the values in an array or writing out Jason.

  • Next we could have another property that will be an array of friends.

  • But instead of putting strings inside of this array, we're going to put more user objects inside of that array so we can put different user objects inside of that ray.

  • And now we have nesting of a raise with objects.

  • And that's how you really get into the power of Jason, where you can start to deeply nest different properties and really show a hierarchy of data as opposed to just a flat form out of data.

  • Like most data format files give you So, for example, for this friends of Ray.

  • We could have a friends of rage and it could have the same properties of name.

  • Favorite number is programmer hobbies and even friends inside of that.

  • And you can start to get a very deeply messed it a great if you really wanted.

  • Then we just have to make sure that we don't put a comma on the very last property value.

  • Keep air that we have close it with a curly brace.

  • And that's our full Jason file created.

  • Now that we understand what Jason is and this in tax involved with writing Jason, I'm going to jump into a live example of me writing Jason file and then parts in that file in Java scares.

  • So I have visual studio code open, and I'm inside of a file called cos dot Jason.

  • We're going to store an array of different companies, and each of these companies is goingto have a name, number of employees, a CEO and their rating out of five.

  • So let's get started by using arson text for creating a rate which is to use an opening and closing square bracket and incited this array.

  • We're going to store different objects So our first object is going to be our first company, which, as we mentioned, has a name and we're just going to give that company name of Big corporation.

  • And then we put the combat the end of the road.

  • We want to give it a number of employees as well.

  • And then this number of employees for this big corporations were going to say that they have 10,000 employees.

  • Then we want to give them a CEO and their CEO.

  • His name is going to be married, and then lastly, they're rating out of five stars is going to be a 3.6.

  • And now we want to store a second company in this array.

  • So we just put a comma at the end of our first company object, open up a new object and then give it the same properties.

  • So we'll say your name and we're just going to get this one.

  • The name of small startup go down to the next line.

  • We got number of employees.

  • In this case.

  • They're just going to have three employees since we're a small company, CEO is next, and this company does not have a CEO because they're so small.

  • So we're going to put no here, which is okay to have different types inside of your Jason option.

  • Because Jason doesn't care what types you're different keys are.

  • They just matters that you have keys and values, so we have no here.

  • And then lastly, we're going to give them a rating.

  • Make sure you put that double coats and their rating here is there's going to be 4.2 or 4.3.

  • And there we go.

  • That is our entire cos dot jace on object.

  • And as you see, we have no errors.

  • But if we, for example, didn't put the quote here, you see that we get an error and that's because we're using V s code and it tells us when we have errors instead of our Jason.

  • So we know that our Jason is always going to be correctly formatted, just like this is here.

  • Now it's looking up this index dot html file here, which is just a super simple file that has an opening script tag that we can put some Java script in here to run our page.

  • So what's creative variable or just call it Cos we're going to copy everything from this cos dot Jason because as I mentioned at the beginning of the video Jason, anything in Jason is valid Java skirt so we can take this Jason directly just pasted into our company's variable.

  • And then if we go down here well on the company's variable, and we checked that out inside of our browser here.

  • As you can see, we have walked this company's variable, and we have both parts of our ray.

  • We have CEO name, number of employees rating, and all of this is the information that we have in this file here that we copied over into our job script file and say they now here we have our other company, but most of the time when you're dealing with Jason, you're going to get it back as a string and not as an actual job script object.

  • So to emulate that, what's around this and back ticks, So it's an actual string, and if you say that you see that now our council, it just has a string instead of an actual object, and we can actually use this object inside of our job is curved, so In order to convert this J sound string into a JavaScript object, we need to use what's called jayson dot parts.

  • So if we go down to our log and we say Jason Dark parsed, we pass it in a string, it'll take that string and convert it into a Java script object.

  • So now, as you can see in here, we have our JavaScript object that we created from this string here, using jayson dot parts to get a choice on object right here.

  • And we can use this inside a job script, for example.

  • We wanted we could get the first company inside about of Ray, we could get their name.

  • And now if we say that you'll see it prints out the first company's name, Second company's name prints it out and so on.

  • And you can do anything that you could do with a normal JavaScript object to this newly part Jason object that we created with jayson dot parts.

  • So I hope this baby was useful for you.

  • As you can see, the actual format for Jason is fairly straightforward.

  • You just have to mostly remember to use double close around all of your different keys because in Java script you don't need the double quotes.

  • But in Jason, you do need these double quotes.

  • Other than that, it's very straightforward.

  • It's easy to read, which is great, because just looking at this, you can tell what it's representing, and you can tell what the different keys and values mean.

  • And it's extremely lightweight.

  • So when you send it across the Internet through different AP eyes, it'll take up very little amount of space, which means it will quickly send back and forth, which gives your user a great end experience.

  • So thank you guys very much for watching you now.

  • Know everything you need to know in order to use Jason and consumed Jason in your future projects.

  • If you guys enjoyed this video, please extra.

  • Leave me like down below, letting me know and subscribe for more tutorial Somewhere to this.

  • Also, when we know down in the comments below what other style tutorials you'd like me to cover, similar to this one in a short of manner as possible.

  • Thank you guys very much for watching.

Hello, everyone.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

B1 中級

10分でJSONを学ぶ (Learn JSON in 10 Minutes)

  • 10 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語