由于无法找到任何解决方案,我被XLSX卡在了JSON转换器上。我想在我的conf.js中将XLSX转换为JSON。这就是我的XLSX的样子。
如果我正在使用XLSX到JSON编辑器,这就是它向我展示的方式。
[{"":"default","Project1":"smoke"},{"":"Specfile1.js","Project1":"Specfile1.js"},{"":"Specfile2.js","Project1":"Specfile2.js"},{"":"Specfile3.js","Project1":"Specfile3.js"},{"":"Specfile4.js","Project1":"Specfile4.js"},{"":"Specfile5.js","Project1":""},{"":"Specfile6.js","Project1":""},{"":"","Project1":"Project2"},{"":"default","Project1":"smoke"},{"":"Specfile1.js","Project1":"Specfile1.js"},{"":"Specfile2.js","Project1":"Specfile2.js"},{"":"Specfile3.js","Project1":"Specfile3.js"},{"":"Specfile4.js","Project1":"Specfile4.js"},{"":"Specfile5.js","Project1":""},{"":"Specfile6.js","Project1":""}]
我不确定我应该如何正确格式化
{
Project1:
{smoke:Specfile1.js,Specfile2.js,Specfile3.js,Specfile4.js,
default: Specfile1.js,Specfile2.js,Specfile3.js,Specfile4.js,Specfile5.js,Specfile6.js
},
Project2:
{smoke: ...,
default: ...,
sanity: .....
}
答案 0 :(得分:0)
我建议将项目拆分成表格。 XLSX按列拆分列(第一行是字符串,同一列中的下一个单元格是值)。如果将其拆分为表格,您将获得更好的结果。如果您逐页使用,您将获得:
{
"Project1": [
{
"smoke": "Specfile1.js",
"default": "Specfile1.js"
},
{
"smoke": "Specfile2.js",
"default": "Specfile2.js"
},
{
"smoke": "Specfile3.js",
"default": "Specfile3.js"
},
{
"smoke": "Specfile4.js",
"default": "Specfile4.js"
}
],
"Project2": [
{
"smoke": "Specfile1.js",
"default": "Specfile1.js"
},
{
"smoke": "Specfile2.js",
"default": "Specfile2.js"
},
{
"smoke": "Specfile3.js",
"default": "Specfile3.js"
},
{
"smoke": "Specfile4.js",
"default": "Specfile4.js"
}
],
"Sanity": [
{
"sanity": "Specfile1.js"
},
{
"sanity": "Specfile2.js"
}
]
}
您可以像这样访问它们:
for(var i = 0; i < Object.keys(test.Project1).length;i++ ) {
console.log(test.Project1[0].smoke);
}
// Specfile1.js Specfile2.js Specfile3.js Specfile4.js