gpt4 book ai didi

javascript - 如何在 Node.js 中遍历 JSON 数组?

转载 作者:可可西里 更新时间:2023-11-01 12:30:14 41 4
gpt4 key购买 nike

我有一个 JSON 数组:

[
{
"art": "A",
"count": "0",
"name": "name1",
"ean": "802.0079.127",
"marker": "null",
"stammkost": "A",
"tablename": "IWEO_IWBB_01062015"
},
{
"art": "A",
"count": "0",
"name": "2",
"ean": "657.7406.559",
"marker": "null",
"stammkost": "A",
"tablename": "IWEO_IWBB_02062015"
}
]

为了遍历 PHP 中的数组,我将使用以下代码来遍历表名:

foreach($jArray as $value){ 
$tablename = $value['tablename'];
//some code
}

我如何在 Node.js 中执行此操作?我发现了很多问题,但没有实际答案。其中大部分来自 2011 年。

最佳答案

var tables = [
{ "art":"A","count":"0","name":"name1","ean":"802.0079.127","marker":"null","stammkost":"A","tablename":"IWEO_IWBB_01062015" },
{ "art":"A","count":"0","name":"2","ean":"657.7406.559","marker":"null","stammkost":"A","tablename":"IWEO_IWBB_02062015" }
];

tables.forEach(function(table) {
var tableName = table.name;
console.log(tableName);
});

关于javascript - 如何在 Node.js 中遍历 JSON 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31254578/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com