What Does JSON Look Like?
JSON is just text that organizes data in a structured way. Think of it like a label on a package:
1{2 "name": "Alice",3 "age": 28,4 "developer": true,5 "city": "San Francisco"6}That's it. Curly braces {} hold key-value pairs. Every key is in double quotes. Values can be text, numbers, true/false, or null.
Think of JSON as...
The 6 Types of JSON Values
1{2 "name": "Alice",3 "age": 28,4 "active": true,5 "nickname": null,6 "address": {7 "city": "SF",8 "zip": "94102"9 },10 "skills": ["JavaScript", "Python", "SQL"]11}| Type | Example | Used For |
|---|---|---|
| String | "hello" | Text, names, IDs, dates |
| Number | 42, 3.14 | Counts, prices, measurements |
| Boolean | true / false | Flags, toggles, yes/no |
| Null | null | "No value" or "unknown" |
| Object | {"key": "value"} | Grouped data (like a record) |
| Array | ["a", "b", "c"] | Lists of items |
Step 1: Make an API Call with curl
Open your terminal and run this command. It fetches real data from a free public API:
1curl https://jsonplaceholder.typicode.com/users/1You'll see something like this:
1{2 "id": 1,3 "name": "Leanne Graham",4 "username": "Bret",5 "email": "[email protected]",6 "phone": "1-770-736-8031 x56442",7 "website": "hildegard.org",8 "company": {9 "name": "Romaguera-Crona",10 "catchPhrase": "Multi-layered client-server neural-net"11 }12}What Just Happened?
Step 2: Make an API Call with JavaScript
1// Paste this in your browser console (F12 → Console)2const response = await fetch('https://jsonplaceholder.typicode.com/users/1');3const user = await response.json();45console.log(user.name); // "Leanne Graham"6console.log(user.email); // "[email protected]"7console.log(user.company.name); // "Romaguera-Crona"Three lines of code. That's all it takes to fetch JSON data and use it in your app.
Step 3: Make an API Call with Python
1import requests23response = requests.get('https://jsonplaceholder.typicode.com/users/1')4user = response.json()56print(user['name']) # Leanne Graham7print(user['email']) # [email protected]8print(user['company']['name']) # Romaguera-CronaReading Nested JSON
Real API data is usually nested — objects inside objects. Access them by chaining keys:
1const data = {2 "user": {3 "profile": {4 "name": "Alice",5 "social": {6 "twitter": "@alice_dev"7 }8 }9 }10};1112// Chain the keys to reach nested values13data.user.profile.name; // "Alice"14data.user.profile.social.twitter; // "@alice_dev"Creating Your Own JSON
You don't just read JSON — you create it when building apps:
1const myData = {2 name: "Your Name",3 skills: ["HTML", "CSS", "JavaScript"],4 experience: { years: 1, level: "beginner" }5};67// Convert to JSON string (for sending to an API)8const jsonString = JSON.stringify(myData, null, 2);9console.log(jsonString);3 Golden Rules
Always use double quotes
Keys and string values must use " not '. This is the #1 beginner mistake.
No trailing commas
The last item in an object or array must NOT have a comma after it.
No comments
JSON does not support // or /* */ comments. Store notes elsewhere.
Try These Tools
Try It Yourself
Write your own JSON object describing yourself. Include a name (string), age (number), a boolean, and an array of hobbies.
Try It Yourself
Edit this JSON and hit validate — if it passes, you wrote valid JSON!
What to Learn Next
Now that you understand JSON basics, here's your learning path: