JSON

Table of contents

Summarise with:

JSON (JavaScript Object Notation) It is a lightweight and widely used data exchange format for creating asynchronous web applications. It is used to represent structured information, always in the form of text that is readable by both humans and the servers with which it communicates, in .json format.

It is often used for working with AJAX as an alternative to the XML format, as the latter is bulkier and therefore less practical for facilitating the rapid exchange of information between servers and users’ computers.

It is worth noting that JSON is a very versatile format, as it enables communication between two programmes that may be written in completely different programming languages, such as Java and Python.

Major companies such as Twitter, Facebook (now Meta), Yahoo and Google opt for the JSON format across all their online services.

What is JSON used for?

JSON is commonly used to transmit data between web applications and services via HTTP as part of the API (Application Programming Interfaces).

It is particularly useful in the development of web and mobile applications because it is easy for both humans and computer systems to understand and process. Furthermore, thanks to its lightweight format, it is more efficient in terms of data transmission than other, more verbose formats, such as XML.

In addition, JSON is also used to facilitate communication between different components of distributed systems and exchange data within systems of the the Internet of Things. Furthermore, JSON files are also useful for storing data temporarily.

The main data structures generated using JSON are:

Objects

These are unordered collections of key-value pairs, where the keys are strings and the values can be any valid data type, such as numbers, strings, Booleans (false or true), nested objects or even arrays.

Example of a JSON object:

{

  «name»: «Juan»,

  «age»: 30,

  «married»: false,

  «hobbies»: [«football», «reading», «travelling»]

}

Arrays

Also known as vectors, these are ordered lists of values, where each value can itself be a JSON object, a string, a number, a Boolean or even another array.

Example of an array in JSON:

[

  {

    «name»: «Ana»,

    «age»: 25

  },

  {

    «name»: «Pedro»,

    «age»: 28

  },

  {

    «name»: «Luisa»,

    «age»: 22

  }

]

JSON or XML?

The choice between JSON and XML depends on the context and the specific requirements of each application or project. Both formats have their advantages and disadvantages, so it is important to consider various factors before deciding which is best in a particular case.

Advantages of JSON

  • It is lighter and has a simpler structure than XML.
  • It is easier for humans to read and write.
  • It is closely related to JavaScript, so they can be easily integrated.
  • It is widely used by most modern web APIs.

 

Advantages of XML

  • It allows for a more complex and hierarchical structure that is better suited to representing complex data and documents with additional metadata.
  • XML supports validation using schemas (XSD) to ensure the integrity and consistency of the data.
  • It has a longer track record and is more widely established across a wide variety of platforms and programming languages.

Share in:

Related articles

Can machine translation replace human translators?

In today's globalised world, machine translation has become an essential tool, enabling people to communicate across language barriers, facilitating the exchange of information and culture. This technology, once a

Glitch

A glitch is a term used in video games to refer to a flaw in a video game. Although it is popularly called a glitch all the errors that we find when playing the game, this is not entirely accurate. There are also other types of glitches

UTM

UTM stands for Urchin Tracking Module and is a system of codes that are added to the end of URLs to track the origin of web traffic. These codes allow marketers and web analysts to identify where visitors are coming from.

Fine-tuning: adaptation of pre-trained models

Fine-Tuning is an advanced technique in Machine Learning that allows pre-trained models to be adapted to specific tasks. Instead of training a model from scratch, which requires large volumes of data and computational power, Fine-Tuning reuses previous knowledge and

Scroll to Top