Skip to content

Commit

Permalink
Use PHP native json_validate in isJson function if available (#48367)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnoordsij authored Sep 12, 2023
1 parent 6d29fad commit a02a39b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a02a39b

Please sign in to comment.