以下是一个具有递归属性的深度嵌套对象。
如何转换以下深度嵌套对象:
如何转换以下深度嵌套对象:
const obj = {
prop1: {
properties: { value: {} },
},
prop2: {
properties: { subProp: { properties: { value: {} } } },
},
prop3: {
properties: { subProp: { properties: { subSubProp: { properties: { value: {} } } } } },
},
};
转换为:
const obj = {
prop1: { value: {} },
prop2: { subProp: { value: {} } },
prop3: { subProp: { subSubProp: { value: {} } } },
};
//if properties exists, else leave as it is (in each level)