diff --git a/src/Pecee/Http/Response.php b/src/Pecee/Http/Response.php index c5730f1..45226e9 100644 --- a/src/Pecee/Http/Response.php +++ b/src/Pecee/Http/Response.php @@ -1,4 +1,5 @@ header('Content-Type: application/json'); + + if (($value instanceof \JsonSerializable) === false && is_array($value) === false) { + throw new \InvalidArgumentException('Invalid type for parameter "value". Must be of type array or object implementing the \JsonSerializable interface.'); + } + + $this->header('Content-type: application/json'); echo json_encode($value); - die(); + exit(0); } /**