JSON

Introduction

JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging data. It is easy to read and write, and language-independent. JSON is commonly used to send data between clients and servers in web applications. Data in JSON is structured as key-value pairs and can include data types like strings, numbers, arrays, objects, booleans, and null.

Syntax

{
  "key": "value",              // string value
  "number": 123,               // numeric value
  "boolean": true,             // boolean value (true/false)
  "nullValue": null,           // null value
  "array": [1, 2, 3],          // array
  "object": {                  // nested object
    "nestedKey": "nestedValue"
  }
}
  • JSON uses double quotes for strings and keys.

  • Keys must be strings.

  • Commas separate key-value pairs, but there should be no trailing comma after the last pair.

Last updated