Skip to main content

Featured

πŸŽ‰ Day 46 — React Mastery Completed (Final Summary & Congratulations!)

πŸŽ‰ Day 46 — React Mastery Completed (Final Summary & Congratulations!) Congratulations, developer! πŸ‘ You’ve successfully completed the 45-Day React.js Roadmap — from understanding the fundamentals to mastering advanced concepts like Redux, Routing, Testing, and Deployment. πŸ“˜ What You’ve Learned ✅ React basics — Components, JSX, Props, and State ✅ Hooks — useState, useEffect, useRef, useMemo, and Custom Hooks ✅ Context API and Redux Toolkit for global state management ✅ Routing with React Router & Protected Routes ✅ Data fetching using Fetch API, Axios, React Query ✅ Advanced Patterns — Compound Components, Render Props, HOCs ✅ Styling — CSS Modules, Styled Components, Theming ✅ Animations, Accessibility, Testing, and Performance Optimization ✅ Deployment on Vercel, Netlify, or GitHub Pages 🧩 Final Project Ideas Now that you’re done, build real-world apps to polish your skills: πŸ“ Task ...

🧾 Day 51: Working with JSON

🧾 Day 51: Working with JSON

JSON (JavaScript Object Notation) is a lightweight format for storing and exchanging data. It’s used widely in APIs and web applications to send structured information between client and server.

πŸ”Ή JSON Basics

JSON represents data as key–value pairs, similar to JavaScript objects, but keys and string values must be enclosed in double quotes.

{
  "name": "Rahul",
  "age": 22,
  "skills": ["HTML", "CSS", "JavaScript"],
  "isDeveloper": true
}

πŸ”Έ Converting JSON ↔ JavaScript

Parsing converts JSON string to JavaScript object, and Stringifying converts object to JSON string.

const jsonData = '{"name":"Rahul","age":22}';
const obj = JSON.parse(jsonData); 
console.log(obj.name); // Rahul

const jsObj = { course: "JavaScript", duration: "30 Days" };
const jsonString = JSON.stringify(jsObj);
console.log(jsonString);

πŸ”Ή JSON in APIs

APIs often send responses in JSON format. You can fetch and parse it easily using fetch().

fetch("https://jsonplaceholder.typicode.com/users")
  .then(response => response.json())
  .then(data => console.log(data));

πŸ§ͺ Try it Yourself

Comments