I have a comparison to make between two different objects, each containing nested objects:
var data = {
"results":{
"Description":"There was a record added",
"resultTimestamp":"2017-03-23T21:56:05Z"
},
"service":"FDSY",
"StartTimestamp":"2017-03-23T21:55:17Z",
"eventId":"033dc019-0b8a-4af22",
"assetId":"TenGigE0/14/0/0.55",
"assetType":"CLCI"
}
and another object structured like this:
var filter = {
"results":{
"Description":"",
},
"service":"",
"eventId":"",
"assetType":""
}
The second object is intended to represent the criteria for filtering the first object. How can I utilize lodash functions to create an object that matches this pattern:
var result = {
"results":{
"Description":"There was a record added"
},
"service":"FDSY",
"eventId":"033dc019-0b8a-4af22",
"assetType":"CLCI"
}
In essence, I require the result to only include key-value pairs that align with the keys specified in the filter object, including those within nested objects.
While not mandatory, I acknowledge that utilizing lodash could simplify this process. Your assistance is greatly appreciated.