Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142382

Find total grandchildren in object and iterate over them?

$
0
0

I have the below object in javascript.

I need to find;

  1. The total amount of "prop3" children - in the below example that would be 7.
  2. Find the first prop3 child, and then iterate over them, until I get to the last one (used in a step-form thingy)

Any ideas?

{
    "d399ca811f45": {
        "prop1": "d399ca811f45",
        "prop2": {},
        "prop3": {
            "1d2097764d06": {
                "header": "value",
                "subprop1": "1d2097764d06"
            }
        }
    },
    "6d0cb4c7748b": {
        "prop1": "6d0cb4c7748b",
        "prop3": {
            "3a29208f0015": {
                "header": "value",
                "subprop1": "3a29208f0015"
            },
            "e8eb0f1b339b": {
                "header": "value",
                "subprop1": "3a29208f0015"
            },
            "05d43aaf7ef7": {
                "header": "value",
                "subprop1": "3a29208f0015"
            }
        }
    },
    "39feecfa5498": {
        "prop1": "39feecfa5498",
        "prop2": {},
        "prop3": {
            "57a07392b86e": {
                "header": "value",
                "subprop1": "3a29208f0015"
            },
            "fd84d411a823": {
                "header": "value",
                "subprop1": "3a29208f0015"
            },
            "75ff469329ab": {
                "header": "value",
                "subprop1": "3a29208f0015"
            }
        }
    }
}

Viewing all articles
Browse latest Browse all 142382

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>