JS Tutorial



JS JSON


JavaScript JSON ๐Ÿ“ฆ

JSON (JavaScript Object Notation) is a lightweight format for storing and transporting data. It's often used when data is sent from a server to a web page.

๐Ÿ”Ž JSON Syntax

  • Data is in name/value pairs.
  • Data is separated by commas.
  • Curly braces {} hold objects.
  • Square brackets [] hold arrays.
{
  "name": "Technorank",
  "type": "Tutorial",
  "topics": ["HTML", "CSS", "JavaScript"]
}

๐Ÿ” Converting Between JSON and JavaScript

1. JSON to JavaScript Object

let jsonString = '{"name":"Aman", "age":22}';
let obj = JSON.parse(jsonString);
console.log(obj.name); // Aman

2. JavaScript Object to JSON

let jsObj = { course: "JavaScript", duration: "4 weeks" };
let jsonData = JSON.stringify(jsObj);
console.log(jsonData); // {"course":"JavaScript","duration":"4 weeks"}

๐Ÿงช Try It Yourself

โœ… When to Use JSON

  • Communicating with APIs
  • Saving structured data
  • Configuration files
Note: JSON keys and string values must be in double quotes "like this".

๐ŸŒŸ Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review