Question : Accessing JSON Data
Answered by : samer-saeid
// JSON object
const data = { "name": "John", "age": 22, "hobby": { "reading" : true, "gaming" : false, "sport" : "football" }, "class" : ["JavaScript", "HTML", "CSS"]
}
// accessing JSON object
console.log(data.name); // John
console.log(data.hobby); // { gaming: false, reading: true, sport: "football"}
console.log(data.hobby.sport); // football
console.log(data.class[1]); // HTML
Source : | Last Update : Sun, 29 May 22