You have to specify fetching mode
$q->fetchAll(PDO::FETCH_ASSOC);
Please specify the Mode of fetching
Change
$json = $q->fetchAll();
to