Reputation: 954
I have a json object :
myJson = [
{"id":"001", "name":"AAA"},
{"id":"002", "name":"BBB"},
{"id":"003", "name":"CCC"},
{"id":"004", "name":"DDD"}
]
How I can remove an element by value of id?
thank for your helps
Upvotes: 1
Views: 4696
Reputation: 7887
you can filter your array... as example: you want to remove every object with the id "003" use this:
myJson = myJson.filter(function(jsonObject) {
return jsonObject.id != "003";
});
Upvotes: 5