Got the result by using the Recursively Traverse an Object method:
this link helps me: https://cheatcode.co/tutorials/how-to-recursively-traverse-an-object-with-javascript.
the backendService:
// Verify the object
isObject(value): any {
return !!(value && typeof value === "object");
};
// Find object in node
findNestedObject(object: {}, keyToMatch: String, valueToMatch: String): any {
if (this.isObject(object)) {
let entries = Object.entries(object);
for (let i = 0; i < entries.length; i += 1) {
const [objectKey, objectValue] = entries[i];
if (objectKey === keyToMatch && objectValue === valueToMatch) {
return object;
}
if (this.isObject(objectValue)) {
let child = this.findNestedObject(objectValue, keyToMatch, valueToMatch);
if (child !== null) {
return child;
}
}
}
}
return null;
};
and call that method in component as:
// Find the nested object by passing node, key, & value
// the this.shop is your backend data or json
let result = this.backendService.findNestedObject(this.data, "id", "dataId");
console.log("Result: ", result);