What is JSON


JSON is an English acronym for JavaScript Object Notation and is a format for representation and the interchange of data between computer applications.

It is a human-readable text format used to represent objects and other data structures and is especially used to transmit structured data over the network, the process is called serialization. JSON is simpler, easier than XML. The elegance of the JSON format comes from being a subset of the JavaScript language (ECMA-262 3rd Edition), which is used alongside this language. Douglas Crockford created the JSON format and standardized it through RFC 4627. The type of media that a JSON document has to send is application/json. The extension for JSON files is .json.

JSON is built on two structures:

1. A collection of name/value pairs. In most languages, this is done as an object, a record, a structure, a dictionary, a hash table, a list of keys, or an associative table.
2. An ordered list of values. In most languages, this is done as an array, a vector, a list, or a string.

These are universal data structures. Almost all modern programming languages ​​support them in one form or another. It makes sense that a data format that is interchangeable with programming languages ​​is also based on these structures.

In JSON, they take one of the following forms:

1. An object is an unordered set of name/value pairs. An object begins with { and ends with }. Each name is followed by : and the name/value pairs are separated by ,
2. A graph is an ordered collection of values. A graph begins with [ and ends with ]. Values ​​are separated by ,
3. A value can be a string in quotation marks, or a number, or true or false or null, or an object or a picture.
4. A string is a sequence of zero or more Unicode characters, placed between quotes, and using escape sequences with the backslash. A character is represented as a single-character string. A string resembles a string of C or Java.
5. A number is very much like a number in C or Java, except that octal and hexadecimal formats are not used.

White spaces can be inserted between any pair of lexical atoms. Except for some details of this encoding, it completely describes the language.

To better understand what the JSON representation means, there are two implementations of the same object, say MACHINE in XML and JSON:

<mark> Opel </ mark>
<color> black </ color>
<traction> on the front </ traction>
<engine> 92 CP, Benzin </ engine>
</ Car>

In JSON, the representation is as follows:

“Mark”: “Opel”,
“Black color”,
“Traction”: “on the front”,
“Engine”: “92CP, BENZIN”
The popularity gained in a short time, thanks to its benefits, has led to the development of JSON analyzer implementations in almost all existing programming languages, from C ++, C #, Java. For this reason, JSON has become a very useful tool for data transfer between different languages, the best example being AJAX.

Another JSON advantage in the competition with XML is speed. Being a simpler format, the native encode/decode functions are faster.

Speed ​​is particularly important in AJAX applications, and since JSON is well suited for HTTP requests, this format is becoming more popular in Web 2.0 application development.

Recent Posts