Recursive Function

An example to run a recursive function for a JSON Object

by Shawn Wood

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<div id="container">

</div>

JavaScript

var data = {
    "comments": [{
        "commentId": "1",
        "parentId": "0",
        "refCommentTypeId": "1",
        "objectName": "",
        "recordId": "",
        "topic": "test topic",
        "text": "This is sample data.",
        "classificationName": "Unclassified",
        "refClassificationId": "0",
        "archived": "0",
        "createdDt": "11/12/2015",
        "createdById": "112",
        "lastUpdatedDt": "11/12/2015",
        "lastUpdatedById": "112",
        "authorName": "Stryker, William",
        "refUserRoleId": "2",
        "authorRole": "Analyst",
        "responseList": [{
            "commentId": "4",
            "parentId": "1",
            "refCommentTypeId": "1",
            "objectName": "",
            "recordId": "",
            "topic": "Inner Test topic",
            "text": "This is sample data.",
            "classificationName": "Unclassified",
            "refClassificationId": "0",
            "archived": "0",
            "createdDt": "11/12/2015",
            "createdById": "112",
            "lastUpdatedDt": "11/12/2015",
            "lastUpdatedById": "112",
            "authorName": "Stryker, William",
            "refUserRoleId": "2",
            "authorRole": "Analyst",
            "responseList": []
        }]
    }, {
        "commentId": "2",
        "parentId": "0",
        "refCommentTypeId": "2",
        "objectName": "",
        "recordId": "",
        "topic": "test topic",
        "text": "This is sample data.",
        "classificationName": "Unclassified",
        "refClassificationId": "0",
        "archived": "0",
        "createdDt": "11/12/2015",
        "createdById": "112",
        "lastUpdatedDt": "11/12/2015",
        "lastUpdatedById": "112",
        "authorName": "Stryker, William",
        "refUserRoleId": "2",
        "authorRole": "Analyst",
        "responseList": []
    }, {
        "commentId": "3",
        "parentId": "0",
        "refCommentTypeId": "3",
        "objectName": "",
  ...