I am looping through an array of objects and I am trying to combine them to a specific JSON:
The array of objects:
[
{
'code': 'LA',
'name': 'Local administrator',
'id': 1
},
{
'code': 'SA',
'name': 'System administrator',
'id': 2
}
]
How can I combine them and have something like this?
[
{
"role":{
"code":"LA",
"name":"Local administrator",
"id":1
}
},
{
"role":{
"code":"SA",
"name":"System administrator",
"id":2
}
}
]
roleproperty?