如何将对象移动到包含嵌套对象的外部对象?
{ criteria:
{ provider: 2,
providerName: 'CLX_gw0',
mcc: null,
mnc: null,
dial_code: null,
active: 1 },
page: 1,
pageSize: 50 }
我想这样:
{
provider: 2,
providerName: 'CLX_gw0',
mcc: null,
mnc: null,
dial_code: null,
active: 1,
page: 1,
pageSize: 50
}
答案 0 :(得分:1)
试试这个。你甚至不需要lodash:
const newObj = Object.assign({}, obj, obj.criteria);
delete newObj.criteria;