function getJsonItemBaseDetailsItem($jsonItem, $post)
{
    global $pof_available_languages;
    global $pof_settings_lastupdate_overwrite;
    if ($pof_settings_lastupdate_overwrite == null) {
        $jsonItem->lastModified = $post->post_modified;
    } else {
        $jsonItem->lastModified = $pof_settings_lastupdate_overwrite;
    }
    $jsonItem->lastModifiedBy = getLastModifiedBy(get_post_meta($post->ID, '_edit_last', true));
    $post_guid = get_post_meta($post->ID, "post_guid", true);
    $jsonItem->guid = $post_guid;
    $lang_obj = new stdClass();
    $lang_obj->lang = 'fi';
    $lang_obj->details = get_site_url() . "/item-json/?postGUID=" . $post_guid . "&lang=fi";
    if ($pof_settings_lastupdate_overwrite == null) {
        $lang_obj->lastModified = $post->post_modified;
    } else {
        $lang_obj->lastModified = $pof_settings_lastupdate_overwrite;
    }
    array_push($jsonItem->languages, $lang_obj);
    foreach ($pof_available_languages as $available_language) {
        $tmp = get_field("title_" . strtolower($available_language), $post->ID);
        if (!empty($tmp)) {
            $lang_obj = new stdClass();
            $lang_obj->lang = $available_language;
            $lang_obj->details = get_site_url() . "/item-json/?postGUID=" . $post_guid . "&lang=" . $available_language;
            if ($pof_settings_lastupdate_overwrite == null) {
                $lang_obj->lastModified = $post->post_modified;
            } else {
                $lang_obj->lastModified = $pof_settings_lastupdate_overwrite;
            }
            array_push($jsonItem->languages, $lang_obj);
        }
    }
    return $jsonItem;
}
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $post_id = $the_query->post->ID;
        }
    }
}
$tree = getJsonTree($post_id);
$tree_hash = hash("md5", serialize($tree));
$tree->program[0]->treeDetails = new stdClass();
if ($pof_settings_lastupdate_overwrite == null) {
    $tree->program[0]->treeDetails->lastModified = date("Y-m-d H:i:s", $lastModified);
} else {
    $tree->program[0]->treeDetails->lastModified = $pof_settings_lastupdate_overwrite;
}
$tree->program[0]->treeDetails->lastModifiedBy = getLastModifiedBy($lastModifiedBy);
$tree->program[0]->treeDetails->hash = $tree_hash;
echo json_encode($tree);
function getJsonTree($root_id)
{
    $classPrograms = "POFTREE\\programs";
    $classProgram = "POFTREE\\program";
    $root_post = get_post($root_id);
    pof_checkDatetime($root_post);
    $program = new $classProgram();
    $program = getJsonItemDetailsProgram($program, $root_post);
    $program->title = $root_post->post_title;
    $program = getJsonItemBaseDetails($program, $root_post);
    $program->agegroups = getJsonAgeGroups($root_post->ID);
    $programs = new $classPrograms();
    $programs->program[0] = $program;