2 回答
TA贡献1854条经验 获得超8个赞
let json = {
"path": "test",
"clients": [
{
"client": "1.2.2.2;1.1.1.1",
"Access_Type": 2,
"name": "test_01"
},
{
"client": "1.2.2.4;1.1.1.4",
"Access_Type": 1,
"name": "test_02"
},
{
"client": "1.3.3.3",
"Access_Type": 1,
"name": "test_03"
}
]
}
let clients = [];
json.clients.map(ele1=>{
let {client,Access_Type,name} = ele1;
client.split(';').map(ele2=>{
clients.push({client:ele2,Access_Type,name})
})
})
json['clients']= clients;
TA贡献1895条经验 获得超3个赞
var bbb = {
"path": "test",
"clients":[]
};
for(var i in aa.clients){
var splitarr = aa.clients[i].client.split(";");
for(var j=0;j<splitarr.length;j++){
bbb["clients"].push({
"client":splitarr[j],
"Access_Type":aa.clients[i].Access_Type,
"name":aa.clients[i].name
})
}
}
console.log(bbb);
添加回答
举报