Skip to content

Commit 9dbd6b1

Browse files
committed
Support json_validate on isJsonResponse
1 parent a67bd42 commit 9dbd6b1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/LaravelDebugbar.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -923,17 +923,19 @@ protected function isJsonResponse(Response $response)
923923
return true;
924924
}
925925

926-
try {
927-
$content = $response->getContent();
926+
$content = $response->getContent();
928927

929-
if (is_string($content)) {
930-
$content = json_decode($content, true);
928+
if (is_string($content)) {
929+
if (function_exists('json_validate')) {
930+
return json_validate($content);
931931
}
932932

933-
if (is_array($content)) {
934-
return true;
935-
}
936-
} catch (Exception $e) {
933+
// PHP <= 8.2 check
934+
json_decode($content, true);
935+
936+
return json_last_error() === JSON_ERROR_NONE;
937+
} elseif (is_array($content)) {
938+
return true;
937939
}
938940

939941
return false;

0 commit comments

Comments
 (0)