-
I have been looking for different implementations and the following is really nice: function is_json(string $var) {
return json_decode($var) && json_last_error() === JSON_ERROR_NONE;
} What you think? |
Beta Was this translation helpful? Give feedback.
Answered by
crynobone
Sep 15, 2023
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Zen0x7
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
json_validate
will be available in PHP 8.3: https://wiki.php.net/rfc/json_validate and you can already use polyfill from https://github.com/symfony/polyfill-php83 right now