Summer Sale! All accounts are 50% off this week.

Hourlee's avatar

Convert object to array

i am using vue paginator and vue-json-to-excel. Vue paginator needs data in object while vue-json-to-excel needs data in array. How can I make this work? Thanks

0 likes
1 reply
ejdelmonico's avatar

@hourlee Try something like this:

const obj = { "1":5,"2":7,"3":0,"4":0,"5":0 };
const resultArray = Object.keys(obj).map(function(key) {
  return [Number(key), obj[key]];
});

console.log(resultArray);
1 like

Please or to participate in this conversation.