How to export all data of a blogs class by code

I need a help to export all data of blogs class rather than classdefination. I have a code but it’s not working for me :slight_smile:

$classId = 1;

    $class = DataObject\ClassDefinition::getById($classId);
    $classDefinitionJson = DataObject\ClassDefinition\Service::generateClassDefinitionJson($class);
    header("Content-type: application/json");
    header("Content-Disposition: attachment; filename=\"class_" . $class->getName() . "_export.json\"");
    echo $classDefinitionJson;

Finally i got the solution i.e.

$blogs = DataObject\Blogs::getList([]);

    $return_array = array();

    foreach ($blogs as $value) {
        $result = new DataObject\Comments\Listing();
        $result->setCondition("o_parentId = ".$value->getId());
        $result->load();

        $all_comments = array();

        foreach ($result as $value1) {
             $all_comments[] = array("Name"=>$value1->getName(),"Comment"=>$value1->getComments(),"Email"=>$value1->getEmail());
        }

        $return_array[] = array("Title"=>$value->getTitle(),"Description"=>$value->getDescription(),"Image"=>$value->getImage(),"comments"=>$all_comments);
    }

    echo json_encode($return_array,JSON_PRETTY_PRINT);

    die();