<?php
error_reporting(0);

$dns_file = __DIR__ . '/dns.json';
$dns_data = is_array($j = json_decode(@file_get_contents($dns_file), true)) ? $j : [];

$out = [];
foreach ($dns_data as $item) {
    if (is_string($item)) {
        $out[] = trim($item);
    } elseif (is_array($item) && isset($item['url'])) {
        $out[] = trim($item['url']);
    }
}

header('Content-Type: application/json; charset=utf-8');
echo json_encode(['dns' => array_values($out)], JSON_UNESCAPED_SLASHES);