Skip to content

What is JSON?

JSON stands for JavaScript Object Notation. It’s a way to store and share data that’s easy for humans to read and for computers to understand. Think of it like a super-organized notebook.

JSON Objects

A JSON object is like a labeled box where you can store things. It holds data in "key-value" pairs, where each piece of data has a name (the key) and a value (like a number, word, or even another box). It’s written with curly braces {}.

For example:

  • Imagine a box called "person" that holds info about someone.
  • Inside, you might have:
    • "name": "Alice" (a key "name" with the value "Alice")
    • "age": 25 (a key "age" with the value 25)

It looks like this: { "name": "Alice", "age": 25 } The keys are always strings (in quotes), and values can be strings, numbers, true/false, or even more objects!

JSON Arrays

A JSON array is like a numbered list. It’s a way to store multiple items in order, without giving each one a specific name. It’s written with square brackets [].

For example:

  • Imagine a list of your favorite fruits.
  • You could write it as: ["apple", "banana", "orange"] Each item gets a number (starting at 0), so "apple" is 0, "banana" is 1, and "orange" is 2. Arrays can hold strings, numbers, objects, or even other arrays.

Putting Them Together

You can mix objects and arrays. For example, a list of people: [ {"name": "Alice", "age": 25}, {"name": "Bob", "age": 30} ] Here, you have an array (the list) with two objects (each person’s info).

Why Are They Useful?

  • Objects are great for describing something with specific details (like a person or a car).
  • Arrays are perfect for keeping track of multiple things in order (like a shopping list or a set of scores). Together, they help organize data for websites, apps, and more!