JSON stands for JavaScript Object Notation, it is a text format for storing and transporting data. Originally developed for JavaScript.

JSON is useful for creating a configuration file for Applications, and for Internet to send data.

Syntax:

  • Data is in name/value pairs

    A name/value pair consists of a field name (in double quotes), followed by a colon :, followed by a value:

    "name":"John"
    
    • JSON names are string, and must be quoted using double quotes "name".

    • JSON values can be a string, number, object, array, boolean, or null. If the value is a string, then it must be double quoted. If it is of other types, you can leave the double quotes.

      {
          "name":"John", 
          "age":31, 
          "city":"New York",
      	  "Male":true,
          "address":{
              "street_address":"21 2nd Street",
              "city":"New York",
              "state":"NY",
              "postal_code":"10021-3100"
          }
      }
      
    • Whitespace, such as spaces, tabs, and line breaks outside a double-quoted string literal are ignored in the syntax. This means you can format your JSON in a way that is most readable for your use case.

      {"a":12} equivalent to {"a":1 2}

      Readability: While whitespace does not affect functionality, using spaces and line breaks can greatly improve the readability of your JSON.

      Whether adding a space after : is a pesonal choice of taste.

      For instance, the above JSON can be formatted as follows.

      { 
           "name": "John", 
           "age": 30, 
           "city": "New York" 
       } 
      
  • Data is separated by commas ,

  • Curly braces hold objects

  • Square brackets hold arrays

References:

https://www.w3schools.com/js/js_json_intro.asp