js 把[{"datetype":"8","name":"6","type":"1","条件":"0","数值":3],改为[{"datetype":"8","name":"6","type":"1","compare_type":"0","compare_val":3}]
时间: 2023-11-29 16:03:43 浏览: 133
八字java源码-Crawler-config:WebArchiv.cz爬虫配置
以下是将给定的JSON字符串进行修改的JavaScript代码:
```javascript
let jsonStr = '[{"datetype":"8","name":"6","type":"1","条件":"0","数值":3}]';
let jsonObj = JSON.parse(jsonStr);
jsonObj[0]["compare_type"] = jsonObj[0]["条件"];
jsonObj[0]["compare_val"] = jsonObj[0]["数值"];
delete jsonObj[0]["条件"];
delete jsonObj[0]["数值"];
jsonStr = JSON.stringify(jsonObj);
console.log(jsonStr); // 输出:[{"datetype":"8","name":"6","type":"1","compare_type":"0","compare_val":3}]
```
阅读全文