0

i have an array structure like below, which has combinedPorts as key with nested array. i can able to iterate and display the properties with .map function in ES6 if know the number of combinedPorts appears, but i need the code to be common if i have N number of combinedPorts as well.

[
    
    {
        "name": "Test Source",
        "combinedPorts": [
            {
                "name": "PortGroup_1",
                "type": "SourcePorts",
                "combinedPorts": [
                    {
                        "name": "Source_1",
                        "type": "SourcePorts",
                        "combinedPorts": [
                            {
                                "name": "Sami_TestSource",
                                "type": "SourcePorts"
                            }
                            
                        ]
                        
                    }
                ]
            }  
            
        ]
        
    }
]

can someone guide me achieve this. Thanks in advance.

Test1234
  • 399
  • 1
  • 6
  • 17
  • This question is different from already asked question. The already asked question is about to single nested array, whereas here the combinedPorts will appear as multiple nested array. Also for this is asked for single array object, In someother object this combined port will appear as single nested array as well. – Test1234 Jun 23 '22 at 15:26
  • It appears that the "What if the "depth" of the data structure is unknown to me?" section of [this](https://stackoverflow.com/a/11922384/17769815) answer in the dupe target addresses your question. – BrokenBenchmark Jun 24 '22 at 02:12

0 Answers0