Can someone please help me change this json:
These are the rules: The nodes of JSON (A) is sorted in no particular order The nodes of JSON (A) is mutable The "subordinate" node must not exist when there is no attached child to it (see markcorderoi or richard) The status indicates employment status, 1=working, 2=ended. All working nodes attached to ended(2) nodes should use the adjacent (uplink) working(1) nodes (ie marcoderoi attached to nssi, removing rudy in the final tree) JSON (B) should not contain ended nodes
JSON A:
[
{
"manager_name": "nssi",
"login_name": "nishanthi",
"status": 2
},
{
"manager_name": "mbarcelona",
"login_name": "nssi",
"status": 1
},
{
"manager_name": "nishanthi",
"login_name": "markcorderoi",
"status": 1
},
{
"manager_name": "mbarcelona",
"login_name": "richard",
"status": 1
},
{
"manager_name": "letecia",
"login_name": "kamran",
"status": 1
},
{
"manager_name": "letecia",
"login_name": "rudy",
"status": 2
},
{
"manager_name": "rudy",
"login_name": "sol",
"status": 2
},
{
"manager_name": "gloria",
"login_name": "maria",
"status": 1
},
{
"manager_name": "markcorderoi",
"login_name": "gloria",
"status": 1
}
]
to this?
JSON B:
[
{
"subordinate":[
{
"subordinate":[
{
"subordinate":[
{
"subordinate":[
{
"name":"maria"
}
],
"name":"gloria"
}
],
"name":"markcorderoi"
}
],
"name":"nssi"
},
{
"name":"richard"
}
],
"name":"mbarcelona"
},
{
"subordinate":[
{
"name":"kamran"
},
{
"name":"sol"
}
],
"name":"letecia"
}
]
I am having really a hard time doing some algorithms using only Javascript.