Menu
Coddy logo textTech

What is a JSON?

Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 15 of 65.

JSON (JavaScript Object Notation) is a way to store data in key-value pairs. Each entry has a key (often a string) and a value that can be a string, number, array, boolean, or even another JSON object. Think of it like a dictionary, where each word (key) has a definition (value).

To create a JSON you would write:

const obj = {
  name: "Alex",
  age: 30,
  preferences: ["sports", "music"]
}

To get the name we would write:

obj.name    // Alex
obj["name"] // Alex

To update (or change) the value we would write:

obj.name = "John"
obj["name"] = "John"
// Both do the same

console.log(obj.name)
// John
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

Cheat sheet

JSON (JavaScript Object Notation) stores data in key-value pairs. Each key has a value that can be a string, number, array, boolean, or another JSON object.

Create a JSON object:

const obj = {
  name: "Alex",
  age: 30,
  preferences: ["sports", "music"]
}

Access values using dot notation or bracket notation:

obj.name    // Alex
obj["name"] // Alex

Update values:

obj.name = "John"
obj["name"] = "John"

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Logic & Flow