我有一个像这样的JSON数据:

<script>
    var data_work_in =[
             {"ID":13,"share":36,"CQty":0,"CPrice": 1},
             {"ID":14,"share":36,"CQty":0,"CPrice": 1}
    ]
data_work_in.CQty = data_work_in.ClipQty%
</script>


我想将CQty的JSON标头重命名为ClipQty%。

请帮忙

最佳答案

如果列未链接,则需要迭代所有元素
您可以创建新列,分配值,然后删除exisitng列,如下所示



 var data_work_in =[
             {"ID":13,"share":36,"CQty":0,"CPrice": 1},
             {"ID":14,"share":36,"CQty":0,"CPrice": 1}
    ];
data_work_in.forEach(e=>{
e["ClipQty%"]=e['CQty'];delete e["CQty"];
})
console.log(data_work_in)

07-24 09:51