我正在使用具有一些奇怪结构的 JSON 数据,例如:
{
"RESULT":
{
"COLUMNS": ["ID","name","ENABLED","perms","vcenabled","vcvalue","checkenabled","checkvalue","indxenabled","indxvalue"],
"DATA": [
[7,"Site-A", 1, "1,2", 1, 1, 1, 0, 0, 0],
[15,"Site-B", 1, "1,2,3,4", 1, 1, 1, 0, 0, 0]
]
},
"ERROR": 0
}
我想创建一些 JavaScript 将这些数据重组为适当的 JSON 结构,以便“列”数组值成为“数据”数组值的键。因此,在运行 JS 进程后,数据类似于以下内容:
[
{"ID":7,"name":"Site-A","ENABLED":1,"perms":"1,2","vcenabled":1,"vcvalue":1,"checkenabled":1,"checkvalue":1,"indxenabled":1,"indxvalue":1},
{"ID":15,"name":"Site-B","ENABLED":1,"perms":"1,2","vcenabled":1,"vcvalue":1,"checkenabled":1,"checkvalue":1,"indxenabled":1,"indxvalue":1}
]
完成 JSON 重组的 JavaScript 最佳实践是什么?我可以使用 JQuery、Foundation JS 等 JS 框架来完成这项任务吗?