After not receiving a proper response on my previous JSON replacement question, I am posting this follow-up query with a more detailed example.
var beforeReplacement=[
{
"Name": "app1",
"id": "1",
"groups": [
{
"id": "test1",
"name": "test grp45",
"desc": "this is a test group"
},
{
"id": "test2",
"name": "test group 2",
"desc": "this is another test group"
}
]
},
{
"Name": "app2",
"id": "2",
"groups": [
{
"id": "test3",
"name": "test group 4",
"desc": "this is a test group"
},
{
"id": "test4",
"name": "test group 4",
"desc": "this is another test group"
}
]
}
]
changed object:
[
{
"Name": "app2",
"id": "2",
"groups": [
{
"id": "test3",
"name": "changed test group 4",
"desc": "this is a test group"
}
]
}
]
var afterReplacement=[
{
"Name": "app1",
"id": "1",
"groups": [
{
"id": "test1",
"name": "test grp45",
"desc": "this is a test group"
},
{
"id": "test2",
"name": "test group 2",
"desc": "this is another test group"
}
]
},
{
"Name": "app2",
"id": "2",
"groups": [
{
"id": "test3",
"name": "changed test group 4",
"desc": "this is a test group"
},
{
"id": "test4",
"name": "test group 4",
"desc": "this is another test group"
}
]
}
]
I updated the name in var beforeReplacement and provided details of the modified object to be received. How can I efficiently replace this changed object in the beforeReplacement array, resulting in an object similar to var afterReplacement?