All right, so before we actually start building our project quiz app, we decided to introduce you
to what Jason is because we're going to use it in our application.
Also, we'll talk a little about Ajax, which actually is a really great tool for every developer.
Mostly Jason and Ajax are used together.
Actually, we're not going to use Ajax in your project, but trust me, it will be a really handy tool
which you can use in the future.
All right.
So what is Jason?
Abbreviation itself stands for JavaScript object notation.
In general, when we exchange data between browser and server that this data should be always text,
we need to send data as a text and when we receive it, then it's always the text.
So Jason is a text syntactically.
It's like JavaScript object.
When we need to send and receive some data from server, then we have to do it in JSON format.
As an official definition, Jason is lightweight data interchange format.
It's very easy to use and it has very simple syntax rules.
Also, data conversion, for example, into JavaScript object happens really fast and easily.
Actually, for now, you may not know anything about server or backend development, but that's not
a problem.
We are not going to use it in our application, but we'll use just browser local storage, which somehow
will imitate real server.
As we said, Jason, data is very much like JavaScript objects, so it will be really easy to understand
for you because you're already familiar with JavaScript objects.
All right, let's go ahead and talk about syntax of Jason.
Data is a written in value pairs.
Names should be surrounded by double quotes.
As for values.
If you have strings, then they are surrounded by double quotes.
But in case of rows of data types, I mean numbers, booleans, arrays, objects.
And now they are not surrounded by double quotes because Jason can recognize those data types.
Also, data is separated by commas.
So Jason values must be one of the following data types.
No string object array, boolean and no.
All right, let's go to Brackett's and get our hands dirty in Jason.
First of all, I'm going to create an usual JavaScript object.
Let's call it my object.
That inside properties and values name John.
Then age 27.
Then next one married.
And assigned to it through.
Next, property is going to be children names that's assigned to it array with two, three values and
and.
Nick.
So as we said, in order to send this data to the server, it should be converted into text for that,
we have a method called Jason Thring ify.
It will transport this object into string and will give it JSON format.
So let's see it practically create new variable and call it my data.
And now, as we said, we need to use a method called Jason Swingy Flight.
Inside parentheses as an argument, we have to insert data which we want to be converted into strength
in this case, our object called my object.
All right, let's run in council.
My data.
And you see that we have here our object, but it looks like as a text, actually it is string and in
order to prove that, we can just check its type using type of operator.
So you see that it's definitely spring.
OK, we have created objects, then we converted it into string and it's ready to be sent to server.
Also, if we take a closer look at this data, you will find that all the properties are surrounded
by double clouds because metal, which we used gave to this data Jason formed.
As for values only John and names inside array are surrounded by double quotes.
No true and right.
S are not surrounded by double because, as we already said, Jason recognized them as number boolean
and right.
And also besides them, it can recognize objects and null as well.
All right.
That was all about sending data to a server.
In this case, we used JSON, that swingy fight.
But what happens when we receive data from server?
As we said, we always receive data as a text.
So we need something that converts text data into JavaScript object.
For that, we have to use another method called JSON that pass at first.
Let's convert our object into Jason format.
For that, I'm going to surround all the properties by double quotes.
Also, we need double quotes for those extreme values.
And then surround entire object by.
We are doing that because data should be taxed and actually this is the form of data which we receive
from server.
OK, in order to convert this data back into JavaScript objects, we need to use Jason the pass method.
So let's change this thing, fly into parts.
Let's save.
And you see that we got here an error.
And of course, it's because we have here line breaks.
So let's go ahead and fix that.
Then save again.
And the city council, we got usual JavaScript objects on which we can manipulate and work by JavaScript.
All right, so that's the way how you can prepare data to send to server using JSON, the three define
method and also how you can convert received text data into usual JavaScript object using Jason that
pass method.
Those methods will be used in next section where we will build this application again.
I want to say that you don't need to know what server is and how to work it back in Web development,
because in our app, we are going to use just browser local storage instead of a real server.
In most cases, JSON is used with Ajax, which is asynchronous JavaScript XML.
And in order to discuss those things, let's move on to the next election.