H
K
L
N
Q
Z

JSON

JavaScript Object Notation, commonly abbreviated as JSON, is a standard data interchange format used to transmit and store data as text. It is functionally very similar to other serialization formats such as XML.

The notation of JSON is very similar to that of data types in JavaScript, hence the name.

How is data encoded in JSON?

JSON has two top-level elements, an object (which consists of key-value pairs) and an array (an ordered set of values). Keys can only be strings, while values can be one of the following types:

  • object: a collection of key-value pairs, enclosed in { }
  • array: an ordered list of values, enclosed in [ ]
  • string: an ordered sequence of text, enclosed in " "
  • number: a numeric value expressed in decimal, with exponent notation allowed
  • boolean: true or false
  • null: lack of a value

JSON can describe nested and complex data structures since both objects and arrays can contain values that might be objects or arrays.

What are the shortcomings of JSON?

JSON’s primary intent was machine-parsable, so it uses punctuation for enclosing literals and delimitation. It also lacks comments, making it quite unfit for manual reading/writing. YAML is another data format that uses reduced punctuation, adds comments, and makes it more suitable for manual editing. It is a strict superset of JSON.

Example

{
  "org": {
    "name": "DeepSource",
    "login": "deepsourcelabs"
  },
  "repo": {
    "name": "good-first-issue",
    "activelyMaintained": true,
    "stats": [
      {
        "type": "stars",
        "count": 400  
      },
      {
        "type": "forks",
        "count": 130 
      }
    ]
  }
}

Automate objective parts of code reviews

Automate objective parts of code reviews

Get started