I want to convert an object like this:
{\"1\":5,\"2\":7,\"3\":0,\"4\":0,\"5\":0,\"6\":0,\"7\":0,\"8\":0,\"9\":0,\"10\":0,\"11\":0,\"12\":0}
Yet another solution if Object.entries won't work for you.
Object.entries
const obj = { '1': 29, '2': 42 }; const arr = Array.from(Object.keys(obj), k=>[`${k}`, obj[k]]); console.log(arr);