-3

My data is currently formatted as below

{
    music: {
            timestamp: 34953045,
            value: 290348530945
            }, 
    phone: {
            timestamp: 34953045,
            value: 2349234.23
            }, 
    health: {
            timestamp: 34953045,
            value: 2938.2039
            }
}

However I would like to transform my data to

[
    {
        timestamp: 34953045,
        value: 290348530945
    }, 
    {
        timestamp: 34953045,
        value: 2349234.23
    }, 
    {
        timestamp: 34953045,
        value: 2938.2039
    }
]

I want to fill rows in an mui-datatable but can't seem to be able to get this to work.

helpmepie
  • 244
  • 1
  • 6
  • 19

1 Answers1

0

You can try with Object.values()

var data = {
    music: {
      timestamp: 34953045,
      value: 290348530945
    }, 
    phone: {
      timestamp: 34953045,
      value: 2349234.23
    }, 
    health: {
      timestamp: 34953045,
      value: 2938.2039
    }
}

data = Object.values(data);
console.log(data);
Mamun
  • 66,969
  • 9
  • 47
  • 59