I need to extract information from deeply nested properties.
Check my structure of array.
let arr = [
{
"key":"test1",
"value":{
"versions":{
"variable_value-1-can-be-different-name-always":{
"obj": "412421",
"translations":{
"trans1-can-be-variable-name":{
"name": '1'
}
}
}
}
}
},
{
"key":"test11/13",
"value":{
"versions":{
"variable_value-2-can-be-different-name-always22":{
"obj": "1111",
"translations":{
"trans2-can-be-variable-name":{
"name": '2'
}
}
}
}
}
}
]
An example array is above.
It is necessary to see if 'translations' has value within the deeply nested objects.
'translations' appears in some cases and not in others. In the array example. above in this object is present, but it may happen that it does not appear.
I need to iterate through the array, and go through all the objects and see if any object has 'translations'
If translations exist return true and return in how many arrays it is located.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/XAiNQ1h
Comments
Post a Comment