是否有一种方便的办法来过滤<条码>bigObject,其中只有<条码>中定义的特性> 过滤界面<> 目标代码>作为产出?
大型物体有许多特性,我想将信息淡化到我需要的财产上(为节省某些地方,不希望/不能够拯救全部物体)。
I prepared the following code as a jsfiddle here.
// My big object
var bigObject = {
prop1: {
prop2: {
prop3: 123,
prop4: 456,
prop5: "TEST"
},
prop6: 789,
prop7: "xxx"
},
prop8: 5.6,
prop9: 3
};
// My "interface" to filter the object
var filterInterface = {
prop1: {
prop2: {
prop3: true,
},
prop7: true
}
};
// My expected result, only the properties of
// big Object which match the interface
var filteredObject = {
prop1: {
prop2: {
prop3: 123,
},
prop7: "xxx"
}
};