如何重新映射 json 数组

how to remap a json array

我正在尝试重新映射以下 JSON 对象

{At Risk: 803, Champions: 847, Need Attention: 275, Hibernating: 1463, Loyal Customers: 1137, …}

我希望结果是这样的

[{
  Segment: "At Risk",
  value: 803
  }, {
  Segment: "Champions",
  value: 847
  }, {
  Segment: "Need Attention",
  value: 275
  }, {
  Segment: "Hibernating",
  value: 1463
  }, {
  Segment: "Loyal Customers",
  value: 113 
}]

感谢任何帮助!

var a = {'At Risk': 803, 'Champions': 847, 'Need Attention': 275, 'Hibernating': 1463, 'Loyal Customers': 1137};

var arr = Object.keys(a).map((k) => ({Segment: k, value: a[k]}));
console.log(arr);