【发布时间】:2020-10-05 16:36:51
【问题描述】:
我想使用循环从包含许多元素的数组中创建 json 对象
我怎样才能从这个数组中返回这个对象?
我的数组:
[
"text 1",
"text 2",
"text 3"
]
我想归还的对象:
return [
{
json: {
message: "text 1"
}
},
{
json: {
message: "text 2"
}
},
{
json: {
message: "text 3"
}
}
]
【问题讨论】:
-
我看不到 json ...
-
考虑使用
Array.map
标签: javascript arrays json object