JSON — தமிழ்

</>Coding Tamilan.← JavaScript course

JavaScript · Lesson 24 / 32 · தமிழ்

JSON

கருத்தைப் புரிந்துகொள்ளுங்கள். Code-ஐ மாற்றி இயக்குங்கள். ஒரு சிறிய பயிற்சியால் கற்றதை உறுதி செய்யுங்கள்.

Detailed notesRunnable JavaScriptPractice + answer

மூலப் பாட விளக்கங்கள் தமிழில் உள்ளன. கூடுதல் concept, practice மற்றும் answer notes ஆங்கிலத்தில் உள்ளன.

01 / Understand

முக்கியக் கருத்து

JSON is a text format for exchanging data. stringify converts a supported JavaScript value into JSON text; parse reads JSON text back into a value.

Learning goal: Explain what the example does, predict its result, and change it to solve the practice task.

02 / Explore

விரிவான விளக்கங்கள்

JSON என்னன்னு தெரியுமா?

JSON (JavaScript Object Notation) என்பது lightweight data-interchange format. Web APIs-ல standard format இதுதான். Humans-க்கும் machines-க்கும் படிக்கவும் parse பண்றதுக்கும் easy.

JavaScript reference fragmentCODE
{
  "name": "Alice",
  "age": 30,
  "isAdmin": false,
  "address": { "city": "New York" },
  "hobbies": ["reading", "coding"],
  "spouse": null
}

JSON.stringify மற்றும் JSON.parse

JavaScript reference fragmentCODE
const user = { name: "Alice", age: 30, active: true };

// JavaScript object → JSON string
const json = JSON.stringify(user);
console.log(json); // '{"name":"Alice","age":30,"active":true}'

// Pretty print
const pretty = JSON.stringify(user, null, 2);

// JSON string → JavaScript object
const parsed = JSON.parse(json);
console.log(parsed.name); // "Alice"

JSON limitations: Functions, undefined, Symbol, circular references — இவை JSON-ல support ஆகல, stringify-ல drop ஆகும் அல்லது error வரும்.

03 / Read & predict

முழுமையான உதாரணம்

Run this complete index.js program in the JavaScript console editor below. The earlier reference fragments may need a browser page or other surrounding setup.

index.js · complete exampleCODE
const text = '{"title":"JavaScript","lessons":32}';
const course = JSON.parse(text);
console.log(course.title);
console.log(JSON.stringify({ lessons: course.lessons + 1 }));
எதிர்பார்க்கும் முடிவைப் பாருங்கள்
JavaScript
{"lessons":33}
04 / Experiment

மாற்றி இயக்கிப் பாருங்கள்

Load the example, change a value, predict the output, and run it again. Use the console output to check your reasoning.

Open editor ↗

Editor load ஆனதும் code-ஐ ஏற்றி Run அழுத்துங்கள்.

OneCompiler என்ற இலவச வெளிப்புற சேவை code-ஐ இயக்குகிறது. Run செய்யும் code அங்கு அனுப்பப்படும். தனிப்பட்ட தகவல்கள் அல்லது secret keys உள்ளிட வேண்டாம்.

05 / Your turn

சிறிய பயிற்சி

Practice challenge

Add a boolean published property before serializing the result.

விடை மற்றும் விளக்கம்

JSON.stringify({lessons: 33, published: true}) produces JSON containing both properties.

தவிர்க்க வேண்டிய தவறு: JSON property names require double quotes. JSON cannot contain comments, functions, or trailing commas.

அடுத்த பாடத்திற்குத் தயாரா?

  • Explain the example in your own words.
  • Complete the challenge before revealing its answer.
  • Describe the common mistake and how to avoid it.
Coding Tamilan · Learn by doing.