Add or change a value of JSON key with jquery or javascript

前端 未结 6 1676
有刺的猬
有刺的猬 2020-12-08 05:09

I have a JSON string(?) that I have returned from $.ajax() and named it data. Some of the values are empty and I need to

6条回答
  •  庸人自扰
    2020-12-08 05:54

    var temp = data.oldKey; // or data['oldKey']
    data.newKey = temp;
    delete data.oldKey;
    

提交回复
热议问题