Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Accessing JSON Data

// 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
Comment

PREVIOUS NEXT
Code Example
Javascript :: Angle Between Hands of a Clock 
Javascript :: clear dict javascript 
Javascript :: methods of object js 
Javascript :: date match mongodb 
Javascript :: javascript save as pdf 
Javascript :: unknown provider angularjs 
Javascript :: ways to open modal in angular 
Javascript :: check property exists in object javascript 
Javascript :: Generate a random Id safely 
Javascript :: node js 
Javascript :: Counting instances of values in an object 
Javascript :: sequelize datetime format 
Javascript :: check a letter in astring js 
Javascript :: javascript get response payload 
Javascript :: routerlink not working 
Javascript :: javascript record video in browser 
Javascript :: function js 
Javascript :: vanilla document.ready function 
Javascript :: chatbot using html and javascript 
Javascript :: js object to c# object 
Javascript :: this in ajax call 
Javascript :: ajax returning html instead of json 
Javascript :: new js 
Javascript :: Forward propagation in NN 
Javascript :: $(...).DataTable is not a function 
Javascript :: update html text 
Javascript :: javascript infinite while loop 
Javascript :: error: Unknown dialect undefined 
Javascript :: angular set time 
Javascript :: unshift javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =