I want to convert nested object in Json Array.
want to convert this below object
{
"ErrorPage": {
"PASS": 2
},
"Automated": {
"PASS": 17,
"FAIL": 31
},
"HomePage(Landing page)": {
"PASS": 1,
"FAIL": 6
}
}
Into json array of object same as mention below
[
{ "category": "ErrorPage"
"PASS": 2
},
{
"category": "Automated"
"PASS": 17,
"FAIL": 31
},
{
"category": "HomePage(Landing page)"
"PASS": 1,
"FAIL": 6
}
]
I am doing this:
this.httpService.getmoduleTest().subscribe((data) => {
const res = data;
this.Arr = Object.keys(res).map(key=>{
return {
"category": key,
"pass": res[key],
"fail" : res[key]
}
})
console.log(this.Arr);
}
I don't know how to set pass and fail value in it.
{"category": key,"pass": res[key], "fail" : res[key]}to{"category": key,...res[key]}