Here i have Array of objects, in this agents array has 0 elements. i have add an object to this. "agents": [{}]
in this i want to add below element:
{
"refURL": "/unifiedconfig/config/agentteam/5020",
"changeStamp": 18,
"agentCount": 0,
"description": "Cumulus All Team",
"name": "CumulusAll",
"peripheral": {
"id": 5000,
"name": "CUCM_PG_1"
},
"peripheralId": 5000,
"supervisorCount": 0,
"agents": [
{}
]
}
I want to add below element to the above in agents array "agents" [{}]
{
"agent": [
{
"refURL": "/unifiedconfig/config/agent/5101",
"agentId": "1300",
"firstName": "Sammy",
"lastName": "Jackson",
"userName": "cgjackson"
},
{
"refURL": "/unifiedconfig/config/agent/5106",
"agentId": "1305",
"firstName": "Angel",
"lastName": "Jolie",
"userName": "cgjolie"
},
{
"refURL": "/unifiedconfig/config/agent/5109",
"agentId": "1308",
"firstName": "Steve",
"lastName": "O",
"userName": "cgsteveo"
}
]
}
This is the final output i want to be achieved
{
"refURL": "/unifiedconfig/config/agentteam/5016",
"changeStamp": 201,
"agentCount": 3,
"description": "Cumulus Finance Team",
"name": "CumulusFinance",
"peripheral": {
"id": 5000,
"name": "CUCM_PG_1"
},
"peripheralId": 5000,
"supervisorCount": 1,
"agents": [
{
"agent": [
{
"refURL": "/unifiedconfig/config/agent/5101",
"agentId": "1300",
"firstName": "Sammy",
"lastName": "Jackson",
"userName": "cgjackson"
},
{
"refURL": "/unifiedconfig/config/agent/5106",
"agentId": "1305",
"firstName": "Angel",
"lastName": "Jolie",
"userName": "cgjolie"
},
{
"refURL": "/unifiedconfig/config/agent/5109",
"agentId": "1308",
"firstName": "Steve",
"lastName": "O",
"userName": "cgsteveo"
}
]
}
],
"supervisors": [
{
"supervisor": [
{
"refURL": "/unifiedconfig/config/agent/5174",
"agentId": "1082",
"firstName": "Rick",
"lastName": "Barrows",
"userName": "[email protected]"
}
]
}
]
}
2
Answers
I replaced answer again, please check.
You can either do it via expression or side-effect. I’m going to name your object
oldObject
and your agents objectagentsObject
.Expression:
Side-effect: