Get database results as json

$db = new DatabaseConnector(); $conn = $db -> getConnection(); $sql = ""; $stmt = $conn -> prepare($sql); $result_set = $stmt -> execute(); $result = $stmt -> fetchAll(PDO::FETCH_ASSOC); $json = json_encode($result); echo($json);