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
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
.splice()
to remove it.
– nnnnnn
Commented
Nov 15, 2012 at 9:36
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";
});