BCA Student Stories & UpdatesLive
JavaScript Objects, Nested Data & JSON Serialization Basics
Objects are keyed collections of properties and values. Everything in web applications—from user accounts to API responses from servers—is modeled using objects and JSON (JavaScript Object Notation).
Day 27 Step-by-Step Practical Flow
🎯1. What You Will Learn Today
JavaScript Objects, Nested Data & JSON Serialization Basics — Comprehensive Practical Guide
Har concept ko visual mental models, code anatomy aur practical industry tips ke sath samjhein.
Objects are keyed collections of properties and values. Everything in web applications—from user accounts to API responses from servers—is modeled using objects and JSON (JavaScript Object Notation).
"Think of an object like a student physical locker with labeled compartments: one label says "Roll Number", another says "Course", another holds a notebook with "Grades". JSON is like flattening all locker contents into a clean text inventory sheet to mail to university headquarters."
👨🏫3. Teacher Demonstration Code
See how properties, nested objects, and JSON serialization work together in application data management.
<!DOCTYPE html>
<html>
<body>
<script>
const student = {
id: "BCA-2026-001",
name: "Diya Patel",
semester: 1,
subjects: ["Computer Basics", "C Programming", "Discrete Mathematics"],
address: {
city: "New Delhi",
pincode: 110001
}
};
console.log("Student Name:", student.name);
console.log("City:", student.address.city);
// Convert object to JSON string (Serialization)
const jsonString = JSON.stringify(student);
console.log("JSON String:", jsonString);
// Parse back to object (Deserialization)
const reconstructed = JSON.parse(jsonString);
console.log("Reconstructed Name:", reconstructed.name);
</script>
</body>
</html>2. Hands-On Practical Lab: Follow Instructions in VS Code
Code like a professional software engineer! Follow the step-by-step instructions below in Visual Studio Code (VS Code) on your PC, test your output locally, and push to GitHub.
Day 27 Practical Task Test Studio
Define const studentRecord = { rollNo: 101, name: "Kavya", isEnrolled: true };
Declare const studentJson = JSON.stringify(studentRecord); and log it to console.
Spot the Bug: Accessing Undefined Nested Property Crash
Tap or click on the exact line below that contains the error:
Click any code lineconst student = { name: "Vikram" // address property is not defined}; console.log(student.address.city); // Throws TypeError: Cannot read properties of undefined!Senior Developer Forensic Analysis:
student.address evaluates to undefined. Attempting to access .city on undefined immediately throws an unhandled TypeError: Cannot read properties of undefined.
📝Independent Practice: Assignment
📄 course-catalog.htmlUniversity Department Course Catalog Object
- •Create day-27/index.html with an array of 3 course objects.
- •Each object must contain code, title, credits, and an instructor nested object.
- •Use Object destructuring to extract course title and credits.
- •Store and retrieve the array using JSON.stringify() and JSON.parse().
Open Visual Studio Code on your PC (code .), create course-catalog.html, paste this complete step-by-step verified code, test in your browser, and push to your GitHub repo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BCA Day 27 - Objects & JSON Serialization</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Segoe UI', Tahoma, sans-serif;
background: #0b1120;
color: white;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.catalog-card {
background: #1e293b;
border: 1px solid #334155;
border-radius: 16px;
padding: 28px;
max-width: 520px;
width: 100%;
}
h1 { font-size: 20px; color: #38bdf8; margin-bottom: 12px; }
pre {
background: #0f172a;
padding: 14px;
border-radius: 8px;
font-size: 12px;
color: #38bdf8;
overflow-x: auto;
max-height: 240px;
}
</style>
</head>
<body>
<div class="catalog-card">
<h1>BCA Department Course Catalog (JSON)</h1>
<pre id="jsonPreview">Serializing catalog...</pre>
</div>
<script>
// 1. Array of course objects with nested instructor object
const courseCatalog = [
{
code: "BCS-011",
title: "Computer Basics and PC Software",
credits: 3,
instructor: { name: "Er. Manoj Kumar", designation: "Lead Curriculum Architect" }
},
{
code: "BCSL-013",
title: "Software Lab (Linux & Web Basics)",
credits: 2,
instructor: { name: "Pankaj Sharma", designation: "Lab Instructor" }
},
{
code: "BCS-012",
title: "Basic Mathematics",
credits: 4,
instructor: { name: "Dr. Uday Verma", designation: "Mathematics Department" }
}
];
// 2. Object destructuring
const [firstCourse] = courseCatalog;
const { code, title, credits, instructor: { name } } = firstCourse;
console.log(`Featured Course: ${code} - ${title} (${credits} Credits) by ${name}`);
// 3. JSON Serialization & Local Storage
const serialized = JSON.stringify(courseCatalog, null, 2);
localStorage.setItem("bca_course_catalog", serialized);
// 4. Retrieve and Parse
const retrieved = JSON.parse(localStorage.getItem("bca_course_catalog"));
console.log("Retrieved parsed count:", retrieved.length);
document.getElementById("jsonPreview").textContent = serialized;
</script>
</body>
</html>🎓4. Viva Check: Mandatory Conceptual Test
What is the standard purpose of JSON.stringify() in web applications?
5. Mandatory Step: Push to GitHub to Unlock Next Lesson
Target Repo: html-css-projects
Exact GitHub Setup Guide & Expected Structure
Day 27 RequirementsFollow these exact folder and file names to prevent verification errors.
index.html: Avoid spaces or custom names like Alan Turing..html or Index.HTML. Linux/GitHub servers are strictly case-sensitive.day-27/ for today so you don't overwrite previous days.main.You are welcome to read all notes, inspect code snippets, and practice all exercises of Day 27 freely! To officially submit your GitHub repository and unlock subsequent days in your portfolio, please complete Day 26: JavaScript Arrays & Modern Transformation Methods: push, map, filter & reduce first.
Complete Day 26 First