Skip to content

Commit 1977d73

Browse files
committed
Support json_validate on isJsonResponse
1 parent a67bd42 commit 1977d73

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/LaravelDebugbar.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -923,17 +923,17 @@ 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);
931-
}
928+
if (function_exists('json_validate')) {
929+
return json_validate($content);
930+
} elseif (is_string($content)) {
931+
// PHP <= 8.2 check
932+
json_decode($content, true);
932933

933-
if (is_array($content)) {
934-
return true;
935-
}
936-
} catch (Exception $e) {
934+
return json_last_error() === JSON_ERROR_NONE;
935+
} elseif (is_array($content)) {
936+
return true;
937937
}
938938

939939
return false;

0 commit comments

Comments
 (0)