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);