var obj = { "results": [{ "division": "xxx", "xxx": "Administration", "id": "0001", "designation": "Chief Managing Director", "name": "Dr. xxx xx xx"}] };
for (var i in obj.results) {
}
Its working
문제
Iam having a Json object in the below format
var obj={"results": [{"division": "xxx", "xxx": "Administration", "id": "0001", "designation": "Chief Managing Director", "name": "Dr. xxx xx xx"}]};
when am looping over this json by using
for (var i in obj.results){
}
when am debugging it is giving me obj.results is undefined.
Please help
해결책
var obj = { "results": [{ "division": "xxx", "xxx": "Administration", "id": "0001", "designation": "Chief Managing Director", "name": "Dr. xxx xx xx"}] };
for (var i in obj.results) {
}
Its working
다른 팁
Here your json is not in correct format. you are missing closing braces. It should be like this :
var obj={"results": [{"division": "xxx", "xxx": "Administration", "id": "0001", "designation": "Chief Managing Director", "name": "Dr. xxx xx xx"}]}
Then your for loop will work properly.
for (var i in obj.results){
}
Note that, obj.results
isn't an array.
I think you are needing this:
for(var i in Object.getOwnPropertyNames(obj.results)){
}