Markdown

JSON

JSON is the Acronym for JavaScript Object Notation

A lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition – December 1999. JSON is a text format that is completely language-independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

{
  "name": "John Smith",
  "age": 35,
  "address": {
    "street": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "zip": "10021"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "fax",
      "number": "646 555-4567"
    }
  ]
}

Data Structure

JSON data is structured as a collection of name-value pairs. The names are strings, and the values can be strings, numbers, booleans, arrays, or other objects. This structure allows for the representation of complex data hierarchies.

  • Example: JSON data describes a person, with properties such as name, age, address, and phone numbers. The address and phone numbers are themselves objects, which are nested within the parent object. This type of nesting can be used to represent more complex data structures.

Syntax

JSON syntax is derived from object notation in JavaScript. It consists of key-value pairs, where keys are strings and values can be strings, numbers, booleans, arrays, or other objects. JSON data is enclosed in curly braces {} and elements are separated by commas.

  • Key-value pairs: In JSON, data is represented as key-value pairs. The key is a string, and the value can be a string, number, boolean, array, or object.
  • Arrays: JSON supports arrays, which are ordered lists of values. Arrays are enclosed in square brackets [] and elements are separated by commas.

History

JSON was originally specified by Douglas Crockford in the early 2000s. The first JSON message was sent in April 2001 by Crockford to Chip Morningstar. Since then, JSON has become a widely used data format for electronic data interchange, particularly in web applications. JSON filenames use the extension .json.

Usage

JSON is used for transmitting data between a server and web application. It is a commonly used data format with diverse uses in electronic data interchange. JSON is a programming language-independent data format, making it versatile for use in many different programming languages.

Articles Tagged JSON

View Additional Articles Tagged JSON