The JSON array is just a JavaScript array, so you can use push and slice .
Here is an example:
var productList = [1,2,3,4,5,6,7,8,9,0] var piecesProuducts = [] for (var i = 0; i <= 4; i++) { piecesProuducts.push(productList.slice(i*2, i*2+2)); } console.log(piecesProuducts)
source share