Skip to content

Commit

Permalink
Support json_validate on isJsonResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Sep 20, 2024
1 parent a67bd42 commit 9dbd6b1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -923,17 +923,19 @@ protected function isJsonResponse(Response $response)
return true;
}

try {
$content = $response->getContent();
$content = $response->getContent();

if (is_string($content)) {
$content = json_decode($content, true);
if (is_string($content)) {
if (function_exists('json_validate')) {
return json_validate($content);
}

if (is_array($content)) {
return true;
}
} catch (Exception $e) {
// PHP <= 8.2 check
json_decode($content, true);

return json_last_error() === JSON_ERROR_NONE;
} elseif (is_array($content)) {
return true;
}

return false;
Expand Down

0 comments on commit 9dbd6b1

Please sign in to comment.