1

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

4

1 回答 1

5

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";
});
于 2012-11-15T09:35:32.500 回答