Javascript: From the response of angular query build I get a response from it which looks like my array attribute,I need to convert it in my final_output out put in this array I get n number of condition & field with n number of depth.so I need to convert my array in to final_output with n number of depth.
Thanks in advance
Input
let array = [
{
"query": {
"condition": "and",
"rules": [
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"condition": "and",
"rules": [
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"condition": "and",
"rules": [
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"condition": "and",
"rules": [
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
}
]
}
]
}
]
}
]
}
}
]
And my final output looks like below
let final_output = [
{
"query": {
must:[
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"bool": {
"must": [
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"bool": {
"must": [
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"bool": {
"must": [
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
},
{
"field": "controlroom.isJurisdictional",
"operator": "=",
"entity": "controlroom"
}
]
}
}
]
}
}
]
}
}
]
}
}
]