JSON untuk Pemula: Belajar dari Nol Sampai Paham API
Kalau kamu baru mulai belajar web development atau backend, JSON adalah salah satu konsep paling fundamental yang wajib dikuasai. Berikut roadmap belajar yang bisa kamu ikuti langkah demi langkah.
Tahap 1: Pahami Struktur Dasar
Mulai dari memahami bahwa JSON hanya terdiri dari 6 tipe data: string, number, boolean, null, object, dan array. Coba baca artikel Apa itu JSON? dulu kalau belum.
Tahap 2: Latihan Baca JSON Nested
Data dunia nyata jarang sesederhana satu level. Coba pahami contoh ini:
{
"order": {
"id": "ORD-001",
"items": [
{ "produk": "Sepatu", "qty": 2, "harga": 250000 },
{ "produk": "Kaos", "qty": 1, "harga": 75000 }
],
"total": 575000
}
}
Untuk mengakses harga produk pertama, kamu perlu jalur: order.items[0].harga. Latihan membaca jalur seperti ini adalah skill yang akan terus kamu pakai saat membaca dokumentasi API.
Tahap 3: Pahami Bagaimana JSON Dipakai di API
Saat frontend memanggil API, biasanya alurnya:
- Frontend kirim request (kadang membawa
bodyberformat JSON, misal saat submit form). - Backend proses, lalu kirim balik response berformat JSON.
- Frontend "parse" JSON tersebut jadi object yang bisa dipakai di kode (misalnya
JSON.parse()di JavaScript).
Tahap 4: Latihan dengan Data Nyata
Coba ambil response dari API publik mana pun (banyak API gratis untuk latihan), lalu paste ke JSONYAMify. Gunakan Tree View untuk eksplorasi struktur, dan coba praktikkan beberapa hal:
- Cari field tertentu lewat fitur pencarian.
- Ubah satu nilai dan lihat bagaimana output JSON-nya berubah.
- Coba convert ke YAML untuk melihat representasi alternatifnya.
Tahap 5: Pelajari Kesalahan Umum dan JSON Schema
Setelah nyaman dengan struktur dasar, lanjut ke 10 Kesalahan Umum Saat Menulis JSON dan JSON Schema untuk level pemahaman yang lebih dalam soal validasi data.
JSON for Beginners: Learn From Scratch to Understanding APIs
If you're just starting out in web or backend development, JSON is one of the most fundamental concepts you'll need to master. Here's a step-by-step learning roadmap.
Stage 1: Understand the Basic Structure
Start by understanding that JSON only has 6 data types: string, number, boolean, null, object, and array. Read What is JSON? first if you haven't.
Stage 2: Practice Reading Nested JSON
Real-world data is rarely a single flat level. Try parsing this example:
{
"order": {
"id": "ORD-001",
"items": [
{ "product": "Shoes", "qty": 2, "price": 250000 },
{ "product": "T-Shirt", "qty": 1, "price": 75000 }
],
"total": 575000
}
}
To access the first product's price, you need the path: order.items[0].price. Practicing reading paths like this is a skill you'll keep using whenever you read API documentation.
Stage 3: Understand How JSON Is Used in APIs
When a frontend calls an API, the flow is usually:
- The frontend sends a request (sometimes with a JSON
body, e.g. when submitting a form). - The backend processes it and sends back a JSON response.
- The frontend "parses" that JSON into an object usable in code (e.g.
JSON.parse()in JavaScript).
Stage 4: Practice With Real Data
Grab a response from any public API (there are plenty of free ones for practice) and paste it into JSONYAMify. Use Tree View to explore the structure, and try:
- Searching for a specific field using the search feature.
- Changing one value and seeing how the output JSON updates.
- Converting it to YAML to see an alternative representation.
Stage 5: Learn Common Mistakes and JSON Schema
Once you're comfortable with the basics, move on to 10 Common JSON Mistakes and JSON Schema for a deeper understanding of data validation.