JSON: all about the JavaScript Object Notation data format

JSON is a file format derived from JavaScript, allowing data to be stored in an organized, human-readable way. Find out everything you need to know about it.

JSON is the acronym for JavaScript Object Notation. It is a open-standard file format allowing data to be stored in an organized, human-readable manner while facilitating access. The data are presented in a text format consisting of “key / value” pairs.

Closely related to JavaScript, this format can still be generated and read by most programming languages. This universality has made it a very popular way to store, organize, read and share data in web applications and services.

Many websites use JSON for data sharing in addition to RSS feeds. For good reason, JSON feeds can be loaded asynchronously more easily than XML / RSS feeds. It is therefore used a lot for asynchronous communication between browser and server, especially as a replacement for XML in some AJAX-type systems.

The history of JSON

douglas crockford json

Originally, JavaScript Object Notation is born from an association between JavaScript and client-side scripting. It was invented by Douglas Crockford, who continues to maintain the official JSON.org website.

The The first official JSON specification is the ECMA-404 standard of 2013.but the official website was launched in 2002. In addition, Yahoo and Google started using it in 2005 / 2006.

How to store JSON items?

Concretely, JavaScript Object Notation objects are only text. It is therefore possible to store them in multiple ways. They can be stored in a database, in a separate text file, in client storage such as cookies or localStorage, or even using the .json format.

Once the content is stored, it can be retrieved and decrypted in different ways and in different languages. With the JavaScript language, we can use the JSON.stringify() and JSON.parse() methods.

JSON vs XML: what is the best data format?

json vs xml

Although XML is still widely used, JSON has gained a lot of popularity. According to Douglas Crockford, this format has indeed several advantages over XML.

In particular, XML is not optimized for data exchange. For good reason, it does not match the data model of most languages.

What are the disadvantages of JSON?

Despite its many advantages, such as its flexibility and conciseness, this data format has several weaknesses. First of all, the absence of a pattern which allows flexibility in terms of data representation also increases the risk of “distorting” the data.

Besides.., the only type of compatible number is the IEEE-754 double-precision floating-point format. It is therefore not possible to take advantage of the more varied and nuanced types of numbers found in many programming languages.

There’s no no date type either. In fact, developers must represent dates as strings of characters. This can lead to problems with format discrepancies. The only alternative is to represent dates as milliseconds since January 1, 1970.

L’lack of feedback also prevents annotating fields. Additional documentation is required, which increases the risk of misunderstandings. Finally, even though its verbosity is less than XML, this data exchange format is not the most concise.

Be the first to comment

Leave a Reply

Your email address will not be published.