I want to remove a specific item from my JSON object, keep the rest of the object BUT, I want that the indexes of to 'recount' or something...
obj = {
"0":{
test: "test",
test: "test"
},
"1": {
test1: "test1",
test1: "test1"
},
"2": {
test2: "test2",
test2: "test2"
}
}
If I remove an item like
delete obj[1];
I do get the following:
obj = {
"0":{
test: "test",
test: "test"
},
"2": {
test2: "test2",
test2: "test2"
}
}
But I would like to have to have the obj with indexes 0 and 1. Because strange enough if I ask the .length of the result (after removing the item) it gives me 3 and I need the correct length in the rest of the application.
Anyone who knows what best practice is in this case?
undefined.