eg.
var data ={items:[{id:"1", name:"Snatch", type:"crime"},{id:"2", name:"Witches of Eastwick", type:"comedy"},{id:"3", name:"X-Men", type:"action"},{id:"4", name:"Ordinary People", type:"drama"},{id:"5", name:"Billy Elliot", type:"drama"},{id:"6", name:"Toy Story", type:"children"}]};
The Jquery Way :
data.items = jQuery.grep(
data.items,function(item,index){return item.id !="1";});
DELETE Way:
delete data.items[0]
data.items.pop();
your items
array will be 1 item shorter.
For example, to add another item to the array using dynamic values:
// The values to put in the itemvar id =7;var name ="The usual suspects";var type ="crime";// Create the item using the valuesvar item ={ id: id, name: name, type: type };// Add the item to the array
data.items.push(item);
摘自:http://stackoverflow.com/questions/4538269/adding-removing-items-from-json-data-with-jquery