Basics of JSON notation
  • 20 Nov 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Basics of JSON notation

  • Dark
    Light
  • PDF

Article Summary

Purpose of the article

Javascript Object Notation (JSON) is used primarily in web technologies to:

  • creating configuration files (e.g. to configure workflows in the Cooperlink application)
  • data storage (e.g. in so-called document or noSQL databases)
  • data transfer (e.g. structure of data exchanged as part of a REST API)
  • or the exploitation of data in a database

This article explains the basics of scoring.

Javascript Object Notation (JSON)

As the name suggests, JSON is a notation, not a language. This means that there are no instructions that can be interpreted by a computer or software. JSON allows you to create data structures in the same way as XML (HTML is a language that is interpreted by web browsers).

Structure

The basic structure of a JSON file is as follows:

{
  "numericKey": numericValue,
  "textKey": "textValue",
  "booleanKey": true,
  "nestedKey":
  {
     "subPropertyKey": value
  },
  "simpleArrayKey": [1, 2, 3],
  "complexArrayKey": [
      {
           "subPropertyKey1": value
      },
      {
           "subPropertyKey2": value
      }
   ]
}

The information contained between curcly-braces is called objects, that is, collections or structures of heterogeneous data elements. The data is called properties and can be of type:

  • simple with key-value pair syntax: "key": value
  • or complex (i.e. combinations of simple collections).

Properties are separated by a comma except when they end a collection.

Property keys are free. But they are interpreted by the software that uses them. A protocol must therefore be defined to establish an interpretable JSON code.
Property values can be of different types: numeric, text (in this case make use of quotation marks ""), boolean, ...

Properties can be nested , that is, they can themselves contain a collection of properties delimited by braces { }.

The information enclosed in square brackets [ ] is an array. An array is a collection of similar data items stored in contiguous memory locations, either properties or objects.

Media

JSON notation can be used through different media:

Tools

There are various free tools to manipulate JSON data with visual aids (colorization of properties in particular) and syntax checking.


Was this article helpful?