records:[{policyValue: "1,3" ,policyName:'hh',,dictList:[{dictKey:'1',dictValue;'zx'}, {dictKey:'2',dictValue;'zx'}]}, {policyValue:"1"policyName:'hh',,dictList:[{dictKey:'1',dictValue;'zx'},{dictKey:'2',dictValue;'zx'}}] 将records数组中policyName字段改为laber 将dictList数组中的dictValue字段改为laber,并将元素组返回
时间: 2023-08-17 22:05:58 浏览: 110
dbf.rar_arcgis_arcgis python_site:www.pudn.com
以下是 JavaScript 代码实现:
```
const updatedRecords = records.map(record => {
const updatedDictList = record.dictList.map(dict => {
return { dictKey: dict.dictKey, laber: dict.dictValue };
});
return { policyValue: record.policyValue, laber: record.policyName, dictList: updatedDictList };
});
console.log(updatedRecords);
```
输出结果为:
```
[
{
"policyValue": "1,3",
"laber": "hh",
"dictList": [
{ "dictKey": "1", "laber": "zx" },
{ "dictKey": "2", "laber": "zx" }
]
},
{
"policyValue": "1",
"laber": "hh",
"dictList": [
{ "dictKey": "1", "laber": "zx" },
{ "dictKey": "2", "laber": "zx" }
]
}
]
```
阅读全文