JSON

What is JSON?

JSON or JavaScript Object Notation is a text representation of structured data without schema based on pairs of key-value and ordered lists. As is mentioned in its name, JSON is derived from JavaScript, but it is supported either natively or with libraries in the most utilized programming languages.

JSON is normally utilized to exchange information between web clients and web servers.

What is JSON used for?

JSON is usually used to exchange data in web applications (for example. sending some data from the client to the server, so it can be shown on a web page, or vice versa). It is something that comes across quite often.

JSON exists as a string — useful when needed to transmit data across a network. It needs to be converted to a native JavaScript file when the data inside needs to be accessed. JavaScript gives out a global JSON object that has methods available for easily converting between the two objects.

A JSON string can be stored in its own file, which is just a normal text file with an extension of .json, and a MIME type of application/JSON.

As described above, JSON is a string whose format very much resembles JavaScript object literal format because it is descended from JavaScript. It is possible to include the same basic data types inside JSON as you can in a standard JavaScript object — strings, numbers, arrays, booleans, and other object literals. This allows a programmer to create a hierarchy of data.

JSON vs. XML.

From web to mobile and personal computers, almost all computer applications that are known today rely on one of two principal standards: JSON and XML. Today, JSON is the most widely-used format, but it only overtook XML in the last five years.

JSON is the native format for data in JavaScript applications. With the popularity that JavaScript gained in the last decade, more JSON messages have been created than any other type of data format. Writing applications in JavaScript almost makes it so that it is obligatory to use JSON for data interchange. Of course, other formats are possible, but they require more effort and thinking than with the easy option, JSON. With JavaScript gaining enormous popularity for application development, JSON closely followed its development as the easy-to-use and easy to access integrated data interchange format.

Developer communities insist that JSON became more popular than XML because of its concise declarative scope and simple semantics that are part of it instead of other reasons.

JSON has been readily praised due to its simplicity and terse semantics, and XML is labeled as an old standard of the past due to its verbosity and seemingly excessive complexity that plagues its code. Many articles and blog posts offer a limited perspective when comparing JSON to XML, leading readers to believe that JSON is a replacement for XML.

JSON is more popular than XML because of JavaScript’s dominance as one of the most widely used languages of today. With JavaScript’s influence on software trends in the last decade, JSON has received increasingly more attention than any other data interchange format.

JSON format examples.

As an example of JSON formatting, here we can see an array of three records:

{

“employees”:[

{“firstName”:”Jahn”, “lastName”:”Dale”},

{“firstName”:”Anne”, “lastName”:”Rodriguez”},

{“firstName”:”Parker”, “lastName”:”James”}

]

}