moizB
2 years agoNew Contributor
How to add an object into an array
Hi
I have the below JSON as input
[
{
"root": [
{
"id": "1",
"nodes": [
],
"parent": "0",
"tags": [
"Approved",
"1.0"
],
"text": "A"
}
]
},
{
"level2": {
"id": "2",
"nodes": [
{
}
],
"parent": "1",
"tags": [
"Approved",
"1.0"
],
"text": "B"
}
}
]
I want the output as
[
{
"root": [
{
"id": "1",
"nodes": [
{
"id": "2",
"nodes": [{}],
"parent": "1",
"tags": [
"Approved",
"1.0"
],
"text": "B"
}
],
"parent": "0",
"tags": [
"Approved",
"1.0"
],
"text": "A"
}
]
}
]
Can anyone please help how this can be achieved?