我有一个数组,其中包含大量二维数组:
var myArray = [
[2260146,2334221,"copy"],
[1226218,2334231,"copy"],
[2230932,-1,"copy"],
[2230933,-1,"copy"],
[2230934,-1,"copy"]
]
我需要将此数组转换为以下形式的对象以将其作为 JSON 发送:
var json = [
{
"s_id": 2260146,
"t_id": 2334221,
"type": "copy"
},
{
"s_id": 1226218,
"t_id": 2334231,
"type": "copy"
},
{
"s_id": 12,
"t_id": -1,
"type": "copy"
}
]
(“s_id”应该是myArray[0][0]
“t_id myArray[0][1]
”和“type”myArray[0][2]
等等。)
如何获得所需形式的数组?提前致谢。