Skip to content

Commit 8a8138a

Browse files
committed
Support json_validate on isJsonResponse
1 parent 825be2c commit 8a8138a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/LaravelDebugbar.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -872,17 +872,15 @@ protected function isJsonResponse(Response $response)
872872
return true;
873873
}
874874

875-
try {
876-
$content = $response->getContent();
875+
$content = $response->getContent();
877876

878-
if (is_string($content)) {
879-
$content = json_decode($content, true);
880-
}
877+
if (function_exists('json_validate')) {
878+
return json_validate($content);
879+
} else if (is_string($content)) {
880+
// PHP <= 8.2 check
881+
json_decode($content, true);
881882

882-
if (is_array($content)) {
883-
return true;
884-
}
885-
} catch (Exception $e) {
883+
return json_last_error() === JSON_ERROR_NONE;
886884
}
887885

888886
return false;

0 commit comments

Comments
 (0)