JSON

JSON

Json, which means « JavaScript Notation Object », is a standard format which stock structured informations and is primarily used to transfer data between a server and a client. It is based on a subset of the JavaScript Programming Language, and is a data format similar to the syntax of JavaScript objects,

1. Why Json is used?

This format is mainly used to exchanged strutured informations, between a server and a client. It also used to communicate by Webservices between two websites or two applications. For example, a website could obtain stock’s information from the warehouse software thanks to Json.

Developers use JSON to work with AJAX (Asynchronous JavaScript and XML). These formats work well together to achieve asynchronous loading of stored data, which means that a website can update its information without refreshing the page.

This is easier to realise this proces with Json than XML. Today, a lot of website use Ajaxand that’s why the Json file has become very popular.

2. Json syntax

JSON object is more or less a normal Javascript object. A JSON object accepts as value the same basic data types as any other Javascript object – strings, numbers, arrays, booleans, and any other literal object. This allows you to prioritize your data like this:

{
  "team": "Secret agent",
  "homeTown": "Metro City",
  "formed": 2001,
  "secretBase": "Super tower",
  "active": true,
  "members": [
    {
      "name": "Bond",
      "lastName" : "James",
      "age": 35,
      "secretIdentity": "007",
      "weapons": [
        "AK-47",
        "grenade",
        "AK-15"
      ]
    },

The file is mainly a simpler and lighter alternative to XML (Extensive Markup Language) which has similar functions.

3. Conclusion

Json is a really useful tool to exchange data. It has a lot of advantages :

  • It able to load information asynchronously so that your website is more responsive and can manage the data flow more easily.
  • Json is simpler and lighter than XML, thanks to its tree structure and simple syntaxe. No learning is required since the syntax uses only a few punctuation marks.
  • Does not depend on any language (open data exchange format) As this format is very open, it is supported by many languages: JavaScript, PHP, Perl, Python, Ruby, Java,…

We can note two major inconveniences:

  • As with any means of data storage, security measures must be taken to ensure the safety of sensitive data.
  • Rudimentary syntax can be a disadvantage in some cases. For example, unlike XML, there is no precise identification of the data (in the form of a tag, for example), so the structure must be known before use.

Sources :


Emmanuelle Gay

0
0

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *