How to convert array of objects into array of arrays

后端 未结 3 1817
无人共我
无人共我 2020-12-12 07:58

The array of objects looks like this:

[
    {\"Number\":64,\"Earning\":160000},{\"Number\":64,\"Earning\":160000},
    {\"Number\":64,\"Earning\":160000},{\"         


        
3条回答
  •  有刺的猬
    2020-12-12 08:47

    If you're using this exact structure, you can do something like this. Where inputData is the first JSON structure, and outputData will be the data outputted.

    var outputData = [];
    
    for(var i = 0; i < inputData.length; i++) {
        var input = inputData[i];
    
        outputData.push([input.Earning, input.Number]);
    }
    

提交回复
热议问题