Skip to content

Commit b323fb2

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

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/LaravelDebugbar.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -872,20 +872,16 @@ 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 {
880+
// PHP >= 8.2 check
881+
json_decode($string, true);
881882

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

891887
/**

0 commit comments

Comments
 (0)