From 208e9d30365b88e30e7598901f93ddb9c568da96 Mon Sep 17 00:00:00 2001 From: Jesper Noordsij Date: Tue, 12 Sep 2023 20:45:06 +0200 Subject: [PATCH] Use PHP native json_validate in isJson function if available --- src/Illuminate/Support/Str.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index da9540e29ede..ae0849434b14 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -452,6 +452,10 @@ public static function isJson($value) return false; } + if (function_exists('json_validate')) { + return json_validate($value, 512); + } + try { json_decode($value, true, 512, JSON_THROW_ON_ERROR); } catch (JsonException) {