js对json格式对象进行增加,修改,删除

// 假设数据为data
var data=[
        {
          "ID":"83d349de-eca4-4974-a8a7-f9b44b48c6f2",
          "IsLimit":null,
          "CustID":"a0e8d714-bd35-4fbe-8af3-ce11d5764bef",
          "CustName":"客户名称1"
        },        
        {
          "ID":"21c75dc0-826d-4ea3-b9a1-8a348cc9505f",
          "IsLimit":null,
          "CustID":"f2c0c9cc-b3de-4375-bb2e-bfc585ff27da",
          "CustName":"客户名称2"
}]; data.forEach((val,index)=>{
val["IsLimit"]=1;// 修改 把IsLimit修改成1
    val["LimitAccount"]=188.0;//增加
     delete val["CustName"];// 删除
})
console.log(data);// 输出之后的结果如下
[
        {
          "ID":"83d349de-eca4-4974-a8a7-f9b44b48c6f2",
          "LimitAccount":188.0,
          "IsLimit":"1",
          "CustID":"a0e8d714-bd35-4fbe-8af3-ce11d5764bef"
        },
        {
          "ID":"21c75dc0-826d-4ea3-b9a1-8a348cc9505f",
          "LimitAccount":188.0,
          "IsLimit":"1",
          "CustID":"f2c0c9cc-b3de-4375-bb2e-bfc585ff27da"
}];

  

上一篇:贝勒爷教你怎样在Mac上安装Microsoft Office


下一篇:Microsoft Office Visio 2013 (安装 + 激活)