diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 1bca2d2a..a9a29aa2 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -872,20 +872,16 @@ protected function isJsonResponse(Response $response) return true; } - try { - $content = $response->getContent(); + $content = $response->getContent(); - if (is_string($content)) { - $content = json_decode($content, true); - } + if (function_exists('json_validate')) { + return json_validate($content); + } else { + // PHP >= 8.2 check + json_decode($string, true); - if (is_array($content)) { - return true; - } - } catch (Exception $e) { + return json_last_error() === JSON_ERROR_NONE; } - - return false; } /**