Как переставить положение во вложенном объекте.
"nextChildLogic": "AND", значение ключа необходимо переместить после ключа "nextChildLogic" и значение
Original input:
[
{
"bankId": 6111,
"ruleSetId": 0,
"name": "qewrf",
"status": "Active",
"defaultAuthMode": "otp",
"description": "qweerrr",
"rules": [
{
"conditions": [
{
"parameter": "Risk Engine Suggestion",
"condition": "Equals",
"value": "CRITICAL",
"level": "first",
"type": "condition"
},
{
"level": "second",
"type": "group",
"nextChildLogic": "AND",
"conditions": [
{
"parameter": "Merchant Name",
"condition": "Equals",
"value": "1212",
"level": "second",
"type": "condition"
},
{
"logic": "AND",
"parameter": "Risk Engine Score",
"condition": "Equals",
"value": "1222",
"level": "second",
"type": "condition"
}
],
"groupLogic": "OR"
},
{
"logic": "OR",
"parameter": "Merchant Name",
"condition": "Equals",
"value": "11111111111",
"level": "first",
"type": "condition"
},
{
"level": "second",
"type": "group",
"nextChildLogic": "AND",
"conditions": [
{
"parameter": "Merchant Name",
"condition": "Contains",
"value": "11111112",
"level": "second",
"type": "condition"
},
{
"logic": "AND",
"parameter": "Merchant Name",
"condition": "Contains",
"value": "1111111113",
"level": "second",
"type": "condition"
}
],
"groupLogic": "OR"
}
],
"modeOfAuth": "otp"
}
],
"user": "admin"
}
]
Ожидаемый результат:
Я хочу обменяться ключом и значением друг с другом, используя цикл, и я хочу желаемый вывод, такой как
[
{
"bankId": 6111,
"ruleSetId": 0,
"name": "qewrf",
"status": "Active",
"defaultAuthMode": "otp",
"description": "qweerrr",
"rules": [
{
"conditions": [
{
"parameter": "Risk Engine Suggestion",
"condition": "Equals",
"value": "CRITICAL",
"level": "first",
"type": "condition"
},
{
"level": "second",
"type": "group",
"nextChildLogic": "AND",
"groupLogic": "OR"
"conditions": [
{
"parameter": "Merchant Name",
"condition": "Equals",
"value": "1212",
"level": "second",
"type": "condition"
},
{
"logic": "AND",
"parameter": "Risk Engine Score",
"condition": "Equals",
"value": "1222",
"level": "second",
"type": "condition"
}
],
},
{
"logic": "OR",
"parameter": "Merchant Name",
"condition": "Equals",
"value": "11111111111",
"level": "first",
"type": "condition"
},
{
"level": "second",
"type": "group",
"nextChildLogic": "AND",
"groupLogic": "OR"
"conditions": [
{
"parameter": "Merchant Name",
"condition": "Contains",
"value": "11111112",
"level": "second",
"type": "condition"
},
{
"logic": "AND",
"parameter": "Merchant Name",
"condition": "Contains",
"value": "1111111113",
"level": "second",
"type": "condition"
}
],
}
],
"modeOfAuth": "otp"
}
],
"user": "admin"
}
]
Все ключ и значение «groupLogic» обмениваются перед «условиями»: массив.