Well, I have a json where I wanted to iterate but inside it there is another one that also wanted to iterate
var json = {
"categories":[
{
"id":1,
"name":"Best Seller",
"childs":[
{
"name":"Novidades",
"id":2,
"parentID":1,
"productCount":1
},
{
"name":"quatro",
"id":7,
"parentID":1,
"productCount":0
}
]
},
{
"id":2,
"name":"Novidades",
"childs":[
{
"name":"tres",
"id":6,
"parentID":2,
"productCount":0
}
]
},
{
"id":6,
"name":"tres",
"childs":[
]
},
{
"id":7,
"name":"quatro",
"childs":[
]
},
{
"id":8,
"name":"cinco",
"childs":[
{
"name":"seis",
"id":9,
"parentID":8,
"productCount":0
}
]
},
{
"id":9,
"name":"seis",
"childs":[
]
}
],
"productTypes":[
{
"key":0,
"value":"Undefined"
},
{
"key":1,
"value":"Book"
}
]
}
How could you push the childs into another array knowing that childs.length > 0
?