JQ对JSON的增删改

 

var userlist={
   "row1":{name:"张三",age:18},
   "row2":{name:"李四",age:15}
}
//方法一 userlist.row1.sex="";//添加 userlist.row3={name:"json",age:16};//添加 userlist.row1.name="kk" ;//修改 userlist.row1={name:"tiger",age:20};//修改 delete userlist.row3.age;//删除 delete userlist.row3;//删除
//方法二 userlist["row2"].sex="";//添加 userlist["row4"]={name:"free",age:26};//添加 userlist["row2"].sex="";//修改 userlist["row2"]={name:"chfree",age:22,sex:""};//修改 delete userlist["row2"].sex;//删除 delete userlist["row2"];//删除 console.log(userlist);

 

posted @ 2013-09-24 15:53  srfree  阅读(1483)  评论(0编辑  收藏  举报