I need some help with JavaScript. The Problem is that i have a JSON data similar as show in follow,but the problem is that i am not able to access all the objects. With my function i am able to access ["x","y","z"], but i am not able to get others "p,q,r.k,a".Can anyone help me to get this thing fixed, please dont use Object.Keys().I dont know how to iterate inside Json Data.
var Objectkeys = function(obj){
a = []
for(var prop in obj){
if(obj.hasOwnProperty(prop)){
a.push(prop)
}
}
return a;
};
var obj = {
x: 1,
y: 2,
z: {
p: "Hello",
q: "Master",
r: {
k: "Rotten",
a: "apple"
}
}
};
window.onload = function () {
console.log(Objectkeys(obj));
//console.log(Object.keys(obj));
}
Thank you