note 115926 deleted from function.json-last-error-msg by tularis
| From: | tularis@php.net | Date: | Thu, 04 Feb 2016 08:29:32 +0000 |
| Subject: | note 115926 deleted from function.json-last-error-msg by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-204846@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
seregynp :
a better way to test JSON
<?php
$json = json_decode('wrong json');
if ($json === null && json_last_error() !== JSON_ERROR_NONE) {
throw new \LogicException(sprintf("Failed to parse json string '%s', error:
'%s'", $json , json_last_error_msg()));
}
?>