36 JSON format

The JSON (JavaScript Object Notation) format is an open format used as an alternative to XML to transmit structured data between a web server and a web application. Its organization logic is similar to XML, but has a different notation. The format gained popularity in web services such as email clients and shopping sites because it can transmit a lot of information between the client and server using fewer characters.

JSON files also work with pairs of keys and values, and instead of markup such as XML, it uses delimiters in sets: {}, []; and "". A typical JSON file is structured as follows:

{
 "localidade 1": {
  "Continente": "África",
  "País": "Angola",
  "Capital": "Luanda"
 },
 "localidade 2": {
  "Continente": "América do Norte",
  "País": "Estados Unidos",
  "Capital": "Washington DC"
 },
 "localidade 3": {
  "Continente": "América Central",
  "País": "México",
  "Capital": "Cidade do México"
 },
 "localidade 4": {
  "Continente": "América do Sul",
  "País": "Brasil",
  "Capital": "Brasília"
 },
 "localidade 5": {
  "Continente": "Europa",
  "País": "Espanha",
  "Capital": "Madri"
 },
 "localidade 6": {
  "Continente": "Europa",
  "País": "Alemanha",
  "Capital": "Berlim"
 },
 "localidade 7": {
  "Continente": "Oceania",
  "País": "Austrália",
  "Capital": "Camberra"
 },
  "localidade 8": {
  "Continente": "Ásia",
  "País": "Japão",
  "Capital": "Tóquio"
 }
}

The { delimiter marks the beginning of a section and } marks its end. The key and value pairs are separated by : and their values when text is in quotation marks (numbers, for example, are not in quotes). In the example below, "location 6" is a key that receives an array of values (Continent, Country and Capital):

"localidade 6": {
  "Continente": "Europa",
  "País": "Alemanha",
  "Capital": "Berlim"
},

Note that the value of "location 6" is a new array of key-value pairs. This new array starts with the delimiter { and ends with }. This logic of linking sets of pairs may be repeated numerous times, creating many levels for the desired data structure.