Nested JSON Objects | How to Iterate over the JSON Object and its Children Objects in Javascript

Published: 19 December 2021
on channel: Azhar Techno Coder
12,840
159

Code :

animals.json

{
"Animals":{
"cat": {
"humanFriendly": [
"Yes"
]
},
"tiger": {
"humanFriendly": [
"No"
]
},
"chettah": {
"humanFriendly": [
"No"
]
},
"lion": {
"humanFriendly": [
"No"
]
},
"jaguar": {
"humanFriendly": [
"No"
]
},
"dog": {
"humanFriendly": [
"Yes",
"No"
]

}
}
}

Program :

const jsonObject = require('./animals.json')

//console.log(jsonObject.Animals.dog)
var typeOfAnimals = jsonObject["Animals"]
value = "lion"
function animalsJson(json,value){
for (index in json){
//console.log(index)
var obj = json[index]
if(value == index){
console.log(index + " : is human Friendly ? "+obj.humanFriendly)
break;
}
}
}

animalsJson(typeOfAnimals,value)


Next Steps :

---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists

► 1. Javascript -    • Javascript Factory  
► 2. Puppetter -    • Puppeteer  
► 3. Cypress -    • Cypress  
► 4. Tech works -    • Video  
► 5. Vbscript Basics To Advanced -    • VBScript Part 1 -  Features Advantage...  
► 6. Jmeter -    • Jmeter Tutorials  
► 7. Excel -    • Videos On Excel  
► 8. Appium -    • Appium  
► 9. Shares -    • Shares  
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------

#nestedJSONobjects
#readJSONObjects
#javascript


On this page of the site you can watch the video online Nested JSON Objects | How to Iterate over the JSON Object and its Children Objects in Javascript with a duration of hours minute second in good quality, which was uploaded by the user Azhar Techno Coder 19 December 2021, share the link with friends and acquaintances, this video has already been watched 12,840 times on youtube and it was liked by 159 viewers. Enjoy your viewing!