<?php
header("Content-Type: application/json; charset=UTF-8");

$file = __DIR__ . "/database.json";

if (!file_exists($file)) {
    echo json_encode([]);
    exit;
}

$data = file_get_contents($file);

// kalau file kosong
if (!$data || trim($data) === "") {
    echo json_encode([]);
    exit;
}

echo $data;