Working with Nested Data
JSON supports nested objects and arrays, allowing you to represent complex data structures. For example:
const employee = {
"name": "Rajveer",
"department": {
"name": "Engineering",
"location": "India"
},
"projects": [
{ "name": "Project A", "status": "In Progress" },
{ "name": "Project B", "status": "Completed" }
]
};
We can access nested properties using dot notation or bracket notation:
console.log(employee.department.name); // Output: Engineering
console.log(employee["projects"][0].name); // Output: Project A
How to Create and Manipulatinag JSON Data in javaScript?
The JavaScript Object Notation (JSON) is a lightweight data interchange format commonly used for transmitting data between the server and a web application. The JSON data is represented as the key-value pairs and is easy to read and write for both humans and machines. In JavaScript, JSON objects can be easily created and manipulated using built-in methods and functions.