I’m attempting to write a function which updates a json key value if an attempt is made to add a new key with same name
So in fiddle – http://jsfiddle.net/adrianjsfiddlenetuser/C6Ssa/57/
When the button “Add” is clicked the jSon array toUpdate should be updated :
name: "addThis2",
id : 10
should become
name: "addThis2",
id : 11
This is not occuring ?
Sample JSON :
{
"toAdd": [
{
"name": "addThis",
"id": 10
}
],
"toRemove": [
{
"name": "removeThis"
}
]
}
You should change the index of array like folowing:
Then you can try