I am writing automation script to validate json responses of REST APIs and i am using faster xml to serialize and convert java object to json format. I have a user case where I have to get the json response and add a new array element to an existing array and post it back. The json response after GET looks like this :
{
"name":"test",
"id":"1234",
"nodes":[
{
"nodeId":"node1"
},
{
"nodeId":"node2"
}
]
}
To this json response, I need to add a third entry for nodes array
{ "nodeId": "node3" } and then post this.
Can someone please help me understand how to add a new array element to an existing array?