JSON stands for JavaScript Object Notation, which is a syntax for storing and exchanging data. It is text, written with JavaScript object notation. It is a lightweight format for storing and transporting data, so it is used when the data is sent from a server to any particular web page.
When we talk about JSON, it is a format in which you can transfer data from a client to a server and from server to client. As we make more dynamic pages JSON is required.
You can extract your data in the form of text with the help of JSON. In JavaScript suppose you are writing any particular code and you are connecting with your web page and there is a communication taking place between the client and the server but the client only wants to extract the data in the form of text rather than any other format or anything included in it, it just wants the plain simple text.
JSON is very simple and easy to understand as it is very similar to JavaScript so in case you are aware of how you write the JavaScript code and how the objects are defined, it is very simple to understand how you work with JSON.
WHY DO WE USE JSON?
The following are the reasons to use JSON;
JSON has a more compact style than XML, and it is often more readable. The lightweight approach of JSON can make significant improvements.
JSON is very fast when it comes to speed and performance. The XML software parsing process can take a long time. JSON uses fewer data overall. So you reduce the cost and increase the parsing speed.
The JSON structure is straightforward and readable. You have an easier time mapping to domain objects, no matter what programming language you are working with.
JSON uses a map data structure rather than XML’s tree. In some situations, key /value pairs can limit what you can do, but you get a predictable and easy-to-understand data model.
COMPARISONS BETWEEN JSON AND XML
Both of these are used for the same purposes, but a lot of people ask why do we need JSON if we have XML already? Now both of these are used for the open data interchange and these are used to convert your data into text and when the communication between clients takes place, both of these are top choices. XML is much more to a path than JSON.
For any ajax application, JSON is faster than and easier when compared to XML, so suppose you are using XML you fast have to fetch an XML document the use the XML Dom to loop through the document and then extract values and store them in variables but while you are using JSON all you need to do is just fetch a JSON string and then do the JSON path for the JSON string and that is all you got to do and that is exactly why people have started preferring JSON rather than XML.
DYNAMIC PAGES
A dynamic page is a web page that displays different content each time it is viewed. There are two types of the web pages;
Web pages that change in response to an action within that web page, such as mouse or keyboard action. Client-side scripting generates client-side content. The client-side content is generated on the user’s computer than on the server. A scripting language like JavaScript allows a web page to respond to the client-side.
The web page changes when the web page is loaded using server-side scripting. Server-side content is the content that is generated when the web page is loaded. For example, login pages, shopping carts, and forums. Scripting languages like PHP and JSP allow web pages to respond to submission events.