Guest Mode:

BCA Student Stories & UpdatesLive

You
Your StorySign in & share
Er. Manoj Kumar
D5
Er. ManojActive nowPages
Day 27Data Structures2 Hours Practical
Push to GitHub to Complete

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).

Interactive Learning Roadmap

Day 27 Step-by-Step Practical Flow

🎯1. What You Will Learn Today

✔Model complex real-world entities using JavaScript object literals { key: value }.
✔Access and modify properties using dot notation and bracket notation.
✔Work with nested objects and arrays of objects (APIs dataset format).
✔Serialize objects to string using JSON.stringify() and deserialize with JSON.parse().
Day 27 MasterclassData Structures

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.

Real-World Purpose Aur Zaroorat

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).

Object literal: const obj = { key: "value", age: 20 };
Dot notation: obj.key — convenient when property name is a known valid identifier.
Bracket notation: obj["key"] — required when property name is dynamic or contains special characters/spaces.
JSON.stringify(obj): Converts a JavaScript object into a JSON string suitable for network transfer or localStorage.
JSON.parse(jsonString): Parses a JSON string back into a live JavaScript object.
Object Destructuring: const { name, roll } = student extracts properties directly into standalone variables.
Dimaag Mein Bithane Ka Model

"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."

💡 Pro Tip: Code ko ratta mat maaro; imagine karo ki browser har tag ko visually kaise draw karta hai.

👨‍🏫3. Teacher Demonstration Code

See how properties, nested objects, and JSON serialization work together in application data management.

Creating Student Profile Object and Serializing to JSONhtml
<!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.

2 Coding Tasks
Interactive Coding TestAuto-Evaluates as you type

Day 27 Practical Task Test Studio

Test Score:0 / 2 Passed
1. Practical Task Specifications & Live Test Checklist:Type code below to pass tests
Task 1Create studentRecord object

Define const studentRecord = { rollNo: 101, name: "Kavya", isEnrolled: true };

⏳ WAITING
Task 2Serialize to JSON string

Declare const studentJson = JSON.stringify(studentRecord); and log it to console.

⏳ WAITING
2. Type HTML & CSS Code:index.html
index.html
⚡ Real-Time Testing Active
Tab inserts 2 spaces • Live DOM refresh219 chars
Live Browser Output:
🔒 http://localhost:5500/index.html
Live
Renders live HTML & CSS typed on the left.
Interactive Bug Detective

Spot the Bug: Accessing Undefined Nested Property Crash

Tap or click on the exact line below that contains the error:

Click any code line
⚠️ Broken Code Inspector
Tap buggy line
1
const student = {
2
name: "Vikram"
3
// address property is not defined
4
};
5
6
console.log(student.address.city); // Throws TypeError: Cannot read properties of undefined!
Stuck? Need a detective clue before checking the solution?

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.

Golden Rule: Always validate code syntax and security attributes before pushing to GitHub!

📝Independent Practice: Assignment

📄 course-catalog.html

University 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().
Submission Evaluation Criteria: Demonstrate proper object creation, nested access, and JSON stringification.
Exact Assignment Solution Code: course-catalog.html

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>
Verified Assignment Code Solution (100% Tested & Ready to Run)

🎓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

Windows 11 Terminal / VS Code
1$
mkdir day-27
Create a new project folder (day-27)
2$
cd day-27
Change working directory to day-27
3$
git checkout -b feature/day-27-objects
4$
git add index.html
5$
git commit -m "feat(day-27): add javascript objects and json serialization"
Commit staged changes with a descriptive message
6$
git push origin feature/day-27-objects
Push local commits directly to your remote GitHub repository
⌨️ Paste into terminal:Ctrl + V✨ Word wrap active (no horizontal cutoff)
Completion Prerequisites VerificationIncomplete Steps
Google Login
✔ Required
VS Code Implementation
Step 4 Viva Check
Own GitHub Project
Required

Exact GitHub Setup Guide & Expected Structure

Day 27 Requirements

Follow these exact folder and file names to prevent verification errors.

1. GitHub Repository
html-css-projects
Must be set to Public
2. Exact FolderNEW
day-27/ or bca-day-27/
Create inside repo root
3. Exact File NameREQUIRED
index.html
⚠️ No spaces or custom names
4. What to Submit Below
https://github.com/YOU/html-css-projects
Or direct link to index.html
Terminal Commands to Create & Push Day 27
1$
# 1. Enter your repository directory
2$
cd html-css-projects
Change working directory to html-css-projects
3$
# 2. Create the exact folder for Day 27
4$
mkdir day-27
Create a new project folder (day-27)
5$
cd day-27
Change working directory to day-27
6$
# 3. Create your code file: index.html
7$
# (Write your Day 27 homework code inside index.html)
8$
# 4. Save, stage, commit and push to GitHub:
9$
git add .
Stage all modified files and new assets for commit
10$
git commit -m "Day 27: JavaScript Objects, Nested Data & JSON Serialization Basics"
Commit staged changes with a descriptive message
11$
git push origin main
Push local commits directly to your remote GitHub repository
⌨️ Paste into terminal:Ctrl + V✨ Word wrap active (no horizontal cutoff)
How to Avoid "Could not find your practical code file" Errors:
1.Use Lowercase index.html: Avoid spaces or custom names like Alan Turing..html or Index.HTML. Linux/GitHub servers are strictly case-sensitive.
2.Separate Day Folders: Create a new folder day-27/ for today so you don't overwrite previous days.
3.Ensure Public Visibility: If your GitHub repo is Private, automated validation cannot inspect your code. Set it to Public.
4.Check on GitHub Website: Before clicking "Verify", open your repo in Google Chrome to confirm your files were pushed to branch main.
📁 github.com/YOUR_USERNAME/html-css-projects
Branch: main
README.md# BCA Practical Portfolio overview
day-01/Day 1 Prior Lesson
└──index.html
day-02/Day 2 Prior Lesson
└──index.html
day-03/Day 3 Prior Lesson
└──index.html
day-04/Day 4 Prior Lesson
└──index.html
day-05/Day 5 Prior Lesson
└──index.html
day-06/Day 6 Prior Lesson
└──index.html
day-07/Day 7 Prior Lesson
└──index.html
day-08/Day 8 Prior Lesson
└──index.html
day-09/Day 9 Prior Lesson
└──index.html
day-10/Day 10 Prior Lesson
└──index.html
└──styles.css
day-11/Day 11 Prior Lesson
└──index.html
day-12/Day 12 Prior Lesson
└──index.html
day-13/Day 13 Prior Lesson
└──index.html
day-14/Day 14 Prior Lesson
└──index.html
day-15/Day 15 Prior Lesson
└──index.html
day-16/Day 16 Prior Lesson
└──index.html
day-17/Day 17 Prior Lesson
└──index.html
day-18/Day 18 Prior Lesson
└──index.html
day-19/Day 19 Prior Lesson
└──index.html
day-20/Day 20 Prior Lesson
└──index.html
└──styles.css
day-21/Day 21 Prior Lesson
└──index.html
day-22/Day 22 Prior Lesson
└──index.html
day-23/Day 23 Prior Lesson
└──index.html
day-24/Day 24 Prior Lesson
└──index.html
day-25/Day 25 Prior Lesson
└──index.html
day-26/Day 26 Prior Lesson
└──index.html
day-27/✨ CREATE THIS FOLDER FOR TODAY (Day 27)
└──index.htmlMust contain: { key: value }, JSON.stringify(), JSON.parse(), destructuring
Sequential Progression Enforced

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
Curriculum & Practical Systems Authored by Er. Manoj Kumar
NextSem Academy • BCA Practical Learning Portal