I have a Json response as follow with multiple repeated arrays and would need to add a new element&value in each array after "bcd" using javascript code.
{
"id": "123",
"discount": [
{
"abc": xx,
"bcd": xxx,
"mc": {
"dca": "xx",
},
"typ": "xx",
"state": "xx",
"mns": []
},
{
"abc": xxx,
"bcd": xxx,
"dca": "xxx",
},
]
}
expected response:
{
"id": "123",
"discount": [
{
"abc": xx,
"bcd": xxx,
"newelement":new value,
"mc": {
"dca": "xx",
},
"typ": "xx",
"state": "xx",
"mns": []
},
{
"abc": xxx,
"bcd": xxx,
"newelement":new value
"dca": "xxx",
},
]
}
Can anyone please suggest how to do this using JavaScript,