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 Mar 6, 2024
1 parent 825be2c commit 8a8138a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,17 +872,15 @@ 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 if (is_string($content)) {
// PHP <= 8.2 check
json_decode($content, true);

if (is_array($content)) {
return true;
}
} catch (Exception $e) {
return json_last_error() === JSON_ERROR_NONE;
}

return false;
Expand Down

0 comments on commit 8a8138a

Please sign in to comment.