diff --git a/src/Helpers/HttpHelper.php b/src/Helpers/HttpHelper.php index 884cfa4e..b3da9448 100644 --- a/src/Helpers/HttpHelper.php +++ b/src/Helpers/HttpHelper.php @@ -20,7 +20,12 @@ class HttpHelper public function outputJSON($data) { - $this->output(json_encode((array) $data)); + $encodedJson = json_encode((array) $data); + $lastError = json_last_error(); + if ($lastError !== JSON_ERROR_NONE) + $this->output('Fatal error while encoding JSON: ' . $lastError . PHP_EOL . PHP_EOL . print_r($data, true)); + else + $this->output($encodedJson); } public function getRequestHeaders()