JSON Typing Practice
JSON syntax rules, all six data types, real-world patterns, and the most common mistakes developers make — with typing practice links.
JSON Data Types
JSON supports exactly six value types — nothing more, nothing less.
| Type | Description |
|---|---|
string | Sequence of Unicode characters in double quotes |
number | Integer or floating-point — no distinction |
boolean | Lowercase literals only (not True/False) |
null | Explicit absence of a value |
array | Ordered list of values of any type |
object | Unordered collection of key-value pairs |
JSON Syntax Rules
- ✓ Keys must be strings enclosed in double quotes
- ✓ Key-value pairs are separated by a colon
: - ✓ Pairs in an object are separated by commas
- ✓ Arrays use square brackets
[]; objects use curly braces{} - ✓ Whitespace (spaces, tabs, newlines) outside strings is ignored
- ✗ No trailing commas — ever
- ✗ No comments — JSON is data, not code
- ✗ No single quotes — always double quotes
Common JSON Mistakes
Trailing comma— JSON is strict — no trailing commas allowed
Wrong
{"a": 1, "b": 2,}Correct
{"a": 1, "b": 2}Single quotes— Both keys and strings must use double quotes
Wrong
{'key': 'value'}Correct
{"key": "value"}Unquoted keys— Keys must always be quoted strings
Wrong
{name: 'Alice'}Correct
{"name": "Alice"}Comments— JSON does not support comments of any kind
Wrong
// This is JSON
{}Correct
{}Undefined value— undefined is a JavaScript concept, not valid JSON
Wrong
{"x": undefined}Correct
{"x": null}Functions / regex— JSON is data-only — no functions or regex literals
Wrong
{"fn": function(){}}Correct
{"fn": null}NaN / Infinity— NaN and Infinity are not valid JSON numbers
Wrong
{"n": NaN}Correct
{"n": null}Unescaped newline— Newlines inside strings must be escaped as \n
Wrong
{"text": "line1
line2"}Correct
{"text": "line1\nline2"}Real-World JSON Patterns
These are the JSON structures you encounter every day as a developer. Type them until the structure feels natural.
REST API Response
{
"status": "success",
"data": {
"id": 12345,
"username": "saurav_dev",
"email": "dev@example.com",
"created_at": "2024-01-15T09:30:00Z",
"is_pro": true,
"stats": {
"wpm": 87,
"accuracy": 97.3,
"tests_completed": 142
}
},
"meta": {
"request_id": "req_8f2a4d",
"duration_ms": 48
}
}package.json (Node.js)
{
"name": "my-app",
"version": "1.0.0",
"description": "A Next.js application",
"main": "index.js",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "^14.2.0",
"react": "^18.3.0",
"react-dom": "^18.3.0"
},
"devDependencies": {
"typescript": "^5.4.0",
"@types/react": "^18.3.0",
"tailwindcss": "^3.4.0"
}
}App Config File
{
"app": {
"name": "CodeSpeedTest",
"version": "2.1.0",
"environment": "production",
"debug": false
},
"database": {
"host": "db.example.com",
"port": 5432,
"name": "codespeedtest_prod",
"pool_size": 10,
"ssl": true
},
"features": {
"ai_suggestions": true,
"leaderboard": true,
"certificates": true,
"race_mode": false
},
"limits": {
"free_tests_per_day": 10,
"max_wpm_record": 300,
"snippet_max_length": 2000
}
}Array of Objects
{
"languages": [
{
"id": 1,
"name": "Python",
"slug": "python",
"paradigm": ["object-oriented", "functional", "procedural"],
"typing": "dynamic",
"popular": true
},
{
"id": 2,
"name": "TypeScript",
"slug": "typescript",
"paradigm": ["object-oriented", "functional"],
"typing": "static",
"popular": true
},
{
"id": 3,
"name": "Rust",
"slug": "rust",
"paradigm": ["systems", "functional"],
"typing": "static",
"popular": false
}
],
"total": 3,
"page": 1
}Deeply Nested Object
{
"user": {
"profile": {
"personal": {
"name": "Alice",
"age": 28
},
"professional": {
"role": "Senior Engineer",
"company": {
"name": "Acme Corp",
"size": "enterprise",
"location": {
"city": "San Francisco",
"country": "US"
}
}
}
},
"preferences": {
"theme": "dark",
"notifications": {
"email": true,
"push": false,
"sms": false
}
}
}
}Practice typing these in CodeSpeedTest →
JSON is the lingua franca of the web. API responses, config files, package manifests — typing JSON quickly and accurately is a core developer skill. Start typing real code now.