var x = { "monthFactoryWaitingRateDataList": [ { "factory": "HZC01", "dayFactoryWaitingRateList": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "days": [ "2023-04-01", "2023-04-02", "2023-04-03", "2023-04-04", "2023-04-05", "2023-04-06", "2023-04-07", "2023-04-08", "2023-04-09", "2023-04-10", "2023-04-11", "2023-04-12", "2023-04-13", "2023-04-14", "2023-04-15", "2023-04-16", "2023-04-17", "2023-04-18", "2023-04-19", "2023-04-20", "2023-04-21", "2023-04-22", "2023-04-23", "2023-04-24", "2023-04-25", "2023-04-26", "2023-04-27", "2023-04-28", "2023-04-29", "2023-04-30" ], "dayStrs": [ "04-01", "04-02", "04-03", "04-04", "04-05", "04-06", "04-07", "04-08", "04-09", "04-10", "04-11", "04-12", "04-13", "04-14", "04-15", "04-16", "04-17", "04-18", "04-19", "04-20", "04-21", "04-22", "04-23", "04-24", "04-25", "04-26", "04-27", "04-28", "04-29", "04-30" ] }, { "factory": "HZC02", "dayFactoryWaitingRateList": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "days": [ "2023-04-01", "2023-04-02", "2023-04-03", "2023-04-04", "2023-04-05", "2023-04-06", "2023-04-07", "2023-04-08", "2023-04-09", "2023-04-10", "2023-04-11", "2023-04-12", "2023-04-13", "2023-04-14", "2023-04-15", "2023-04-16", "2023-04-17", "2023-04-18", "2023-04-19", "2023-04-20", "2023-04-21", "2023-04-22", "2023-04-23", "2023-04-24", "2023-04-25", "2023-04-26", "2023-04-27", "2023-04-28", "2023-04-29", "2023-04-30" ], "dayStrs": [ "04-01", "04-02", "04-03", "04-04", "04-05", "04-06", "04-07", "04-08", "04-09", "04-10", "04-11", "04-12", "04-13", "04-14", "04-15", "04-16", "04-17", "04-18", "04-19", "04-20", "04-21", "04-22", "04-23", "04-24", "04-25", "04-26", "04-27", "04-28", "04-29", "04-30" ] } ] }; //var data1 = x.monthFactoryWaitingRateDataList[0] var data0 = Object.keys(x)[0] var data1 = Object.values(x)[0][1] let column = Object.keys(Object.values(x)[0][0]); var data3 = Object.keys(Object.values(x)[0][0]) let content = []; // for (let i=0; i< data1.dayFactoryWaitingRateList.length;i++){ for (let i = 0; i<Object.values(x)[0].length;i++){ for (let j =0 ; j<Object.values(Object.values(x)[0][i])[1].length;j++){ let contentLine = []; contentLine.push(Object.values(Object.values(x)[0][i])[0],Object.values(Object.values(x)[0][i])[1][j],Object.values(Object.values(x)[0][i])[2][j],Object.values(Object.values(x)[0][i])[3][j]); var zd1 = Object.keys(Object.values(x)[0][i]).slice(0,[1]); //将每行的数据都作为一个数组塞进content数组 content.push(contentLine); } } //let column = []; //for (let i=0; i< data1.dayFactoryWaitingRateList.length;i++){ //column.push(`col${i + 1}`); //} result = {}; // result.column = JSON.stringify(column); result.column = column; result.content = content; // return result; console.log(result); 该代码在JS工具中运行正常,放到JS解析器中就报错服务器空间未响应,而且不管怎么改,一直是这个报错 |