PDF

What is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. JSON is commonly used for transmitting data in web applications.

Why Use JSON?

  • Simple to Understand: JSON is easy to read, which makes it a great choice for developers and even beginners.
  • Language Independent: JSON is language-agnostic, meaning it can be used with many programming languages.
  • Lightweight: It is a text-based format that results in smaller data sizes, which is faster to transmit.

Basic Structure of JSON

JSON data is organized in key/value pairs. Here’s the general syntax:

{
  "key1": "value1",
  "key2": "value2"
}

In this example:

  • Curly braces {} define an object.
  • Each key is a string (like "key1") followed by a colon.
  • Each value can be a string, number, object, array, true, false, or null.

Example of JSON

{
  "name": "Alice",
  "age": 15,
  "isStudent": true,
  "subjects": ["Math", "Science",
  "History"],
  "address": {"city": "New York", "zip": "10001"}
}

In this example, we have:

  • A name key with the value

Ask a followup question

Loading...