diff --git a/Model/Parser/Html.php b/Model/Parser/Html.php
index 660c92d..2213896 100644
--- a/Model/Parser/Html.php
+++ b/Model/Parser/Html.php
@@ -187,20 +187,21 @@ private function getProductIds(string $html): array
return $productIds;
}
-
+
private function json_validate($json, $depth = 512, $flags = 0)
{
- // First character check to ensure the string starts with `{` or `[` (to improve perfrormace)
- $trimmedJson = ltrim($json);
- if (!is_string($json) || ($trimmedJson[0] !== '{' && $trimmedJson[0] !== '[')) {
+ if (!is_string($json)) {
return false;
}
- try {
- json_decode($json, false, $depth, $flags | JSON_THROW_ON_ERROR);
- return true;
- } catch (\JsonException $e) {
+ $trimmedJson = ltrim($json);
+ // First character check to ensure the string starts with `{` or `[` (to improve perfrormace)
+ if ($trimmedJson[0] !== '{' && $trimmedJson[0] !== '[') {
return false;
}
+
+ // Decode JSON and check for errors
+ json_decode($json, false, $depth, $flags);
+ return json_last_error() === JSON_ERROR_NONE;
}
}