可以通过以下方法循环遍历JSON数组并取值:
const jsonArray = [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}];
for (let i = 0; i < jsonArray.length; i++) {
console.log(jsonArray[i].name);
console.log(jsonArray[i].age);
}
const jsonArray = [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}];
jsonArray.forEach(item => {
console.log(item.name);
console.log(item.age);
});
const jsonArray = [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}];
for (const item of jsonArray) {
console.log(item.name);
console.log(item.age);
}
这些方法可以用来循环遍历JSON数组并取出需要的值。