{ "5": 0, "6": 10, "7": 10, "8": 9, "9": 4 }js转[{label:'5月',value:0}]格式

const jsonData = { "5": 0, "6": 10, "7": 10, "8": 9, "9": 4 };

const resultArray = Object.keys(jsonData).map(key => ({ label: key + "月", value: jsonData[key] }));

console.log(resultArray);

 

 const jsonData = { "5": 0, "6": 10, "7": 10, "8": 9, "9": 4 }; const resultArray = Object.keys(jsonData).map(key => [key + "月", jsonData[key]]); console.log(resultArray);

 

 

posted @ 2023-10-16 14:46  小林222  阅读(28)  评论(0)    收藏  举报