I have an array of objects containing data in a key-value format. Here is an example:
"data": [
{
"groupBy": "InvalidAuth",
"count": 41
},
{
"groupBy": "InvalidAuthEmpty",
"count": 75
},
{
"groupBy": "InvalidAuthSQL",
"count": 75
},
{
"groupBy": "Unsecured",
"count": 75
}
]
I want to transform this data into the following format, where "count" is renamed as "value" and "groupBy" is renamed as "name". How can I achieve this programmatically using TypeScript or JavaScript?
data:[
{value:41, name:'InvalidAuth'},
{value:75, name:'InvalidAuthEmpty'},
{value:75, name:'InvalidAuthSQL'},
{value:75, name:'Unsecured'}
]
The original format does not work with e-charts, as it only accepts data in the value-name form.
Can someone assist me with this conversion?
Thank you.