js 2 D配列回転Json配列再回転jsonオブジェクト配列

720 ワード

function jsonParam(data){  //data       
    var tableColumns = data[0]
    var datajson = {}
    var jsonresult = []
    for (var i = 0; i < data.length; i++) {
      for (var j = 0; j < tableColumns.length; j++) {
        datajson.indexArgs = data[i][0]
        datajson.templateArgs = data[i][1]
        datajson.rate = data[i][2]
        datajson.demandId = data[i][3]
      }
      jsonresult.push(datajson)
      datajson = {}
    }
    console.log(JSON.stringify(jsonresult))
    console.log(jsonresult)//json  
    return JSON.stringify(jsonresult);
}

結果:[{"indexArgs":[Angle 8.0 MHZ],[templateArgs]:[parameter 1:8000.0 HZ],[rate]:[1000],[demandId]:[2240568012882482]]