JSON and its Common Operations

β What is JSON?
JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate.
It is primarily used for:
Data storage
Data exchange between client and server
APIs and web services (like REST)
πΉ JSON Syntax Basics
Data is in name/value pairs
Data is separated by commas
Curly braces
{}
hold objectsSquare brackets
[]
hold arrays
Example:
{
"name": "Alice",
"age": 25,
"isStudent": false,
"skills": ["JavaScript", "Python"]
}
πΉ Common JSON Operations in JavaScript
1. Parse JSON (string β object)
Convert a JSON string into a JavaScript object.
const jsonStr = '{"name":"Alice","age":25}';
const obj = JSON.parse(jsonStr);
console.log(obj.name); // Alice
2. Stringify (object β string)
Convert a JavaScript object into a JSON string.
const obj = { name: "Bob", age: 30 };
const jsonStr = JSON.stringify(obj);
console.log(jsonStr); // {"name":"Bob","age":30}
3. Accessing JSON Data
Once parsed, JSON behaves like a regular JavaScript object.
const data = JSON.parse('{"city":"Mumbai","temp":32}');
console.log(data.city); // Mumbai
4. Modifying JSON
You can change values once itβs parsed into an object.
let user = JSON.parse('{"name":"Tom"}');
user.name = "Jerry";
console.log(JSON.stringify(user)); // {"name":"Jerry"}
πΈ Summary Table
Operation | Method | Description |
Parse JSON | JSON.parse() | Converts JSON string to JS object |
Stringify Object | JSON.stringify() | Converts JS object to JSON string |
Subscribe to my newsletter
Read articles from Sagar Kumar Jha directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sagar Kumar Jha
Sagar Kumar Jha
Softwares are art and I am an artist