loop through nested json object typescript

Solutions on MaxInterview for loop through nested json object typescript by the best coders in the world

showing results for - "loop through nested json object typescript"
Salvatore
04 Jun 2020
1var catalog = 
2{
3    "products": [
4        {
5            "name": "prod 1",
6            "versions": [
7                "ver 1",
8                "ver 2"
9            ]
10        },
11        {
12            "name": "prod 2",
13            "versions": [
14                "ver 1",
15                "ver 2"
16            ]
17        }
18    ]
19};
20
21for(var i = 0; i < catalog.products.length; i++)
22{
23    var product = catalog.products[i];
24    var productName = product.name;
25    for(var j = 0; j < product.versions.length; j++)
26    {
27        var version = product.versions[j];
28    }
29}
30