diff --git a/lib/special_cases.php b/lib/special_cases.php index 25c5e476..8b9e12ff 100644 --- a/lib/special_cases.php +++ b/lib/special_cases.php @@ -37,7 +37,7 @@ function json_decode(string $json, bool $assoc = false, int $depth = 512, int $flags = 0): mixed { $data = \json_decode($json, $assoc, $depth, $flags); - if (JSON_ERROR_NONE !== json_last_error()) { + if (!($flags & JSON_THROW_ON_ERROR) && JSON_ERROR_NONE !== json_last_error()) { throw JsonException::createFromPhpError(); } return $data; diff --git a/tests/JsonDecodeTest.php b/tests/JsonDecodeTest.php new file mode 100644 index 00000000..661fe178 --- /dev/null +++ b/tests/JsonDecodeTest.php @@ -0,0 +1,16 @@ +