mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

* Add `json_validate(string $json, int $depth = 512, int $flags = 0): bool` from https://wiki.php.net/rfc/json_validate * In json_validate, use a different set of C no-op functions for creating/updating arrays/objects when validating while reusing the unmodified parser/scanner code * Forbid unsupported flags in json_validate() * Remove test of passing NULL as parameter (normal behavior of https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg for internal functions) Co-authored-by: jcm <juan.carlos.morales@tradebyte.com>
17 lines
513 B
PHP
17 lines
513 B
PHP
<?php
|
|
|
|
function json_validate_trycatchdump($json, $depth = 512, $flags = 0) {
|
|
try {
|
|
var_dump(json_validate($json, $depth, $flags));
|
|
} catch (JsonException $e) {
|
|
echo "JsonException: {$e->getCode()} {$e->getMessage()}". PHP_EOL;
|
|
} catch (Exception $e) {
|
|
echo "Exception: {$e->getCode()} {$e->getMessage()}". PHP_EOL;
|
|
} catch (Error $e) {
|
|
echo "Error: {$e->getCode()} {$e->getMessage()}". PHP_EOL;
|
|
}
|
|
|
|
var_dump(json_last_error(), json_last_error_msg());
|
|
}
|
|
|
|
?>
|