[Solved] How to split a single JSON object into one JSON nested arrays? [closed]


Try like this.

I have looped the items and generated the object and pushed it to class array.

var data = {
  "Class": [{
    "StudentName": [
      "Ash",
      "Win"
    ],
    "Rank": [
      "1",
      "2"
    ],
    "ID": [
      "001",
      "002"
    ]
  }]
};
var result = {"Class":[]}
data.Class.forEach(function(details) {
  details.StudentName.forEach(function(det,i) {
    var rs = {
      "StudentName" : details.StudentName[i],
      "Rank" : details.Rank[i],
      "ID" : details.ID[i]
    }
    result.Class.push(rs);
  })
})

console.log(result);

solved How to split a single JSON object into one JSON nested arrays? [closed]