var playlist = JSON.parse('{"VideoID" : {"VideoTitle" : "the title of the video"} }');
for(var video in playlist){
document.write(video + " "+ video.title +"<br>");
}
输出为:VideoID undefined
我希望将其视为:VideoID视频标题
答案 0 :(得分:2)
正确用法是:
for(var video in playlist){
document.write(video + " "+ playlist[video].VideoTitle +"<br>");
}
答案 1 :(得分:0)
这应该有效,
var playlist = JSON.parse('{"VideoID" : {"VideoTitle" : "the title of the video"} }');
document.write(playlist.VideoID.VideoTitle);