Parse Json array in JavaScript
This question already has an answer here:
array.forEach(item => console.log(item.Name))
array.forEach(item => console.log(item.Status.Id))
你不能使用数组作为变量,所以替换为arr
并尝试跟随,
var arr = [
{"Name":"Test", "Status":{"Id":100, "Alias":"A"}},
{"Name":"Test2", "Status":{"Id":101, "Alias":"B"}},
{"Name":"Test3", "Status":{"Id":102, "Alias":"C"}}
];
arr.forEach(function(item){
console.log('Name: ' + item.Name);
console.log('Status Id: ' + item.Status.Id);
console.log('Status Alias: ' + item.Status.Alias);
});
链接地址: http://www.djcxy.com/p/52018.html
下一篇: 使用JavaScript解析Json数组