[Chartjs]-How to convert JSON data to object that contains other objects?

1👍

You can use a reducer function for this:

const data = [{
  "A": 400
}, {
  "B": 1597
}, {
  "C": 1567
}].reduce((acc, curr) => {
  Object.keys(curr).forEach(key => acc[key] = curr[key]);
  return acc
}, {})

console.log(data)

Leave a comment