I am trying to read following JSON:
{
"items":[
{
"snippet":{
"title":"Pharrell Williams - Happy (12AM)",
"categoryId":"10"
},
"topicDetails":{
"topicIds":[
"/m/04mn81",
"/m/0zdjzxm"
]
}
}
]
}
I've to read the TopicIds from the json. I've tried following to read the topicIds but it doesn't work. Please tell me what's wrong here:
$.each(jsonResponse.items,function(key, value){
$.each(value.topicDetails,function(k,v){
for(var i=0, len = k.length; i< len; i++){
alert(v[i]);
}
});
});
}
It says there is no property `length'.
topicDetailsis not an array and so has nolengthproperty.$.each(value.topicDetails.topicIds)insteadCannot read property 'topicIds' of undefinedlengthof an object key, rather than the value.