How to i convert the followin array to tree for q-tree components



  • please i need help on this, I’ve searched for hours and cant find a solution.

    please how do i remove the keys(8,26 and root) and convert it into a tree structure for quasar tree component.

    { “8”: [
    { “id”: 14, “user_id”: 4, “post_id”: 17, “parent_id”: 8, “content”: “ok”,“created_at”: “2018-04-19 08:55:23”,
    “user”: { “id”: 4, “name”: “mentor”}
    },
    { “id”: 55, “user_id”: 4, “post_id”: 17, “parent_id”: 8, “content”: “hello”, “created_at”: “2018-10-28 20:43:25”,
    “user”: { “id”: 4, “name”: “mentor”}
    }
    ],

    “26”: [
    { “id”: 27, “user_id”: 4, “post_id”: 17, “parent_id”: 26, “content”: “goood”, “created_at”: “2018-05-26 10:27:45”,
    “user”: { “id”: 4, “name”: “mentor”}
    },
    { “id”: 56, “user_id”: 4, “post_id”: 17, “parent_id”: 26, “content”: “ok ok ok”, “created_at”: “2018-10-28 20:43:36”,
    “user”: { “id”: 4, “name”: “mentor”}
    },
    { “id”: 57, “user_id”: 4, “post_id”: 17, “parent_id”: 26, “content”: “hhfhsjfdjhffd”, “created_at”: “2018-10-28 20:44:06”,
    “user”: { “id”: 4, “name”: “mentor”}
    }
    ],

    “root”: [
    { “id”: 8, “user_id”: 4, “post_id”: 17, “parent_id”: null, “content”: “hello”,“created_at”: “2018-04-18 17:51:25”,
    “user”: { “id”: 4, “name”: “mentor”}
    },
    { “id”: 26, “user_id”: 4, “post_id”: 17, “parent_id”: null, “content”: “hello”,“created_at”: “2018-05-26 10:27:37”,
    “user”: { “id”: 4, “name”: “mentor” }
    }
    ]
    }

    thanks