Tijo  Johnson C

Tijo Johnson C

  • NA
  • 136
  • 9.3k

How to format json data to array format.

Dec 21 2019 2:44 AM
How to format json data to array format and nested arrays are in object like {} without square brackets in typscript.
 
Now return data as :
{
"ProductID": 1,
"Category": [{
"CategoryID": 1,
"SubCategory": [{
"SubCategoryID": 1,
}]
}]
}
 
I want converted output data as in typescript:
 
[{
"ProductID": 1,
"Category": {
"CategoryID": 1,
"SubCategory": {
"SubCategoryID": 1,
}
}
}]
 
I have tried

return this.restApi.getProductBin().subscribe((data: {}) => {
const usersJson: any[] = Array.of(data);
})

Answers (3)